Spenserrrr commented on code in PR #58021:
URL: https://github.com/apache/spark/pull/58021#discussion_r3794708286
##########
python/pyspark/pandas/tests/test_numpy_compat.py:
##########
@@ -264,6 +263,32 @@ def test_np_fmod(self):
self.assert_eq(np.fmod(psdf.x1, psdf.x2), np.fmod(pdf.x1, pdf.x2),
almost=True)
+ def test_np_modf(self):
+ # np.modf(x) returns a tuple (fractional part, integral part).
+ for pdf in (
Review Comment:
Thanks for the suggestion! After adding these tests, I found that my
original implementation didn't actually work on a DataFrame. A DataFrame uses a
different __array_ufunc__ than Series/Index. Series and Index share
IndexOpsMixin.__array_ufunc__, but DataFrame.__array_ufunc__ applies the ufunc
per column and calls .rename() on each result. This assumes a single output, so
a multi-output tuple broke it ('tuple' object has no attribute 'rename'). I've
updated DataFrame.__array_ufunc__ to detect the per-column tuple and regroup
the results into a tuple of DataFrames, matching pandas' np.modf(DataFrame). I
also added the DataFrame and Index test cases as well. Thanks for catching this!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]