Skip to content

Commit 645aeb5

Browse files
Debian Science Teamrebecca-palmer
Debian Science Team
authored andcommitted
918206
Using this and not upstream's __array_priority__ fix pandas-dev/pandas@ad2a14f to allow np.array += DataFrame to remain in-place (same object ID / other views also affected) and an array (not a DataFrame). Author: jbrockmendel, Rebecca N. Palmer <[email protected]> Origin: upstream Bug-Debian: https://bugs.debian.org/918206 https://bugs.debian.org/923707 Forwarded: not-needed Gbp-Pq: Name 918206.patch
1 parent 2e7a987 commit 645aeb5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pandas/core/generic.py

+2
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,8 @@ def __array__(self, dtype=None):
16071607

16081608
def __array_wrap__(self, result, context=None):
16091609
d = self._construct_axes_dict(self._AXIS_ORDERS, copy=False)
1610+
if context is not None and context[0]==np.matmul and not hasattr(context[1][0],'index'):
1611+
d.pop('index',None)
16101612
return self._constructor(result, **d).__finalize__(self)
16111613

16121614
# ideally we would define this to avoid the getattr checks, but

pandas/tests/frame/test_analytics.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -2283,8 +2283,11 @@ def test_matmul(self):
22832283

22842284
# np.array @ DataFrame
22852285
result = operator.matmul(a.values, b)
2286+
assert isinstance(result, DataFrame)
2287+
assert result.columns.equals(b.columns)
2288+
assert result.index.equals(pd.Index(range(3)))
22862289
expected = np.dot(a.values, b.values)
2287-
tm.assert_almost_equal(result, expected)
2290+
tm.assert_almost_equal(result.values, expected)
22882291

22892292
# nested list @ DataFrame (__rmatmul__)
22902293
result = operator.matmul(a.values.tolist(), b)

0 commit comments

Comments
 (0)