Skip to content

Commit 89cc7f2

Browse files
matsmaiwaldanother-green
authored andcommitted
DOC: Highlighted role of index alignment in DataFrame.dot(other) (pandas-dev#26480) (pandas-dev#26496)
1 parent ef87d02 commit 89cc7f2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pandas/core/frame.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,9 @@ def dot(self, other):
944944
Notes
945945
-----
946946
The dimensions of DataFrame and other must be compatible in order to
947-
compute the matrix multiplication.
947+
compute the matrix multiplication. In addition, the column names of
948+
DataFrame and the index of other must contain the same values, as they
949+
will be aligned prior to the multiplication.
948950
949951
The dot method for Series computes the inner product, instead of the
950952
matrix product here.
@@ -982,6 +984,14 @@ def dot(self, other):
982984
0 1
983985
0 1 4
984986
1 2 2
987+
988+
Note how shuffling of the objects does not change the result.
989+
990+
>>> s2 = s.reindex([1, 0, 2, 3])
991+
>>> df.dot(s2)
992+
0 -4
993+
1 5
994+
dtype: int64
985995
"""
986996
if isinstance(other, (Series, DataFrame)):
987997
common = self.columns.union(other.index)

0 commit comments

Comments
 (0)