Skip to content

BUG: Fix ndarray + DataFrame ops #23114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 14, 2018
4 changes: 4 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,10 @@ def __round__(self, decimals=0):
# ----------------------------------------------------------------------
# Array Interface

# This is also set in IndexOpsMixin
# GH#23114 Ensure ndarray.__op__(DataFrame) returns NotImplemented
__array_priority__ = 1000

def __array__(self, dtype=None):
return com.values_from_object(self)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arithmetic/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def test_numeric_arr_rdiv_tdscalar(self, three_days, numeric_idx, box):
if box is not pd.Index and broken:
# np.timedelta64(3, 'D') / 2 == np.timedelta64(1, 'D')
raise pytest.xfail("timedelta64 not converted to nanos; "
"Tick division not imlpemented")
"Tick division not implemented")

expected = TimedeltaIndex(['3 Days', '36 Hours'])

Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/arithmetic/test_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ def test_objarr_radd_str_invalid(self, dtype, data, box):
operator.sub, ops.rsub])
def test_objarr_add_invalid(self, op, box):
# invalid ops
if box is pd.DataFrame and op is ops.radd:
pytest.xfail(reason="DataFrame op incorrectly casts the np.array"
"case to M8[ns]")

obj_ser = tm.makeObjectSeries()
obj_ser.name = 'objects'
Expand Down