File tree 2 files changed +6
-1
lines changed
2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -1607,6 +1607,8 @@ def __array__(self, dtype=None):
1607
1607
1608
1608
def __array_wrap__ (self , result , context = None ):
1609
1609
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 )
1610
1612
return self ._constructor (result , ** d ).__finalize__ (self )
1611
1613
1612
1614
# ideally we would define this to avoid the getattr checks, but
Original file line number Diff line number Diff line change @@ -2283,8 +2283,11 @@ def test_matmul(self):
2283
2283
2284
2284
# np.array @ DataFrame
2285
2285
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 )))
2286
2289
expected = np .dot (a .values , b .values )
2287
- tm .assert_almost_equal (result , expected )
2290
+ tm .assert_almost_equal (result . values , expected )
2288
2291
2289
2292
# nested list @ DataFrame (__rmatmul__)
2290
2293
result = operator .matmul (a .values .tolist (), b )
You can’t perform that action at this time.
0 commit comments