Skip to content

Commit ae860f5

Browse files
Debian Science Teamrebecca-palmer
Debian Science Team
authored andcommitted
array_series_matmul
Author: Ming Li Origin: upstream Bug-Debian: https://bugs.debian.org/923708 Forwarded: not-needed Gbp-Pq: Name array_series_matmul.patch
1 parent 3e70ba8 commit ae860f5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@ def __matmul__(self, other):
20582058

20592059
def __rmatmul__(self, other):
20602060
""" Matrix multiplication using binary `@` operator in Python>=3.5 """
2061-
return self.dot(other)
2061+
return self.dot(np.transpose(other)).T
20622062

20632063
@Substitution(klass='Series')
20642064
@Appender(base._shared_docs['searchsorted'])

pandas/tests/series/test_analytics.py

+5
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,11 @@ def test_matmul(self):
950950
expected = np.dot(a.values, a.values)
951951
assert_almost_equal(result, expected)
952952

953+
# np.array (matrix) @ Series (__rmatmul__)
954+
result = operator.matmul(b.T.values, a)
955+
expected = np.dot(b.T.values, a.values)
956+
assert_almost_equal(result, expected)
957+
953958
# mixed dtype DataFrame @ Series
954959
a['p'] = int(a.p)
955960
result = operator.matmul(b.T, a)

0 commit comments

Comments
 (0)