Skip to content

Commit f7f0c59

Browse files
HubertKldatapythonista
authored andcommitted
DOC: Updating the docstring of Series.dot (#22890)
1 parent 4f71755 commit f7f0c59

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

pandas/core/series.py

+41-4
Original file line numberDiff line numberDiff line change
@@ -2063,16 +2063,53 @@ def autocorr(self, lag=1):
20632063

20642064
def dot(self, other):
20652065
"""
2066-
Matrix multiplication with DataFrame or inner-product with Series
2067-
objects. Can also be called using `self @ other` in Python >= 3.5.
2066+
Compute the dot product between the Series and the columns of other.
2067+
2068+
This method computes the dot product between the Series and another
2069+
one, or the Series and each columns of a DataFrame, or the Series and
2070+
each columns of an array.
2071+
2072+
It can also be called using `self @ other` in Python >= 3.5.
20682073
20692074
Parameters
20702075
----------
2071-
other : Series or DataFrame
2076+
other : Series, DataFrame or array-like
2077+
The other object to compute the dot product with its columns.
20722078
20732079
Returns
20742080
-------
2075-
dot_product : scalar or Series
2081+
scalar, Series or numpy.ndarray
2082+
Return the dot product of the Series and other if other is a
2083+
Series, the Series of the dot product of Series and each rows of
2084+
other if other is a DataFrame or a numpy.ndarray between the Series
2085+
and each columns of the numpy array.
2086+
2087+
See Also
2088+
--------
2089+
DataFrame.dot: Compute the matrix product with the DataFrame.
2090+
Series.mul: Multiplication of series and other, element-wise.
2091+
2092+
Notes
2093+
-----
2094+
The Series and other has to share the same index if other is a Series
2095+
or a DataFrame.
2096+
2097+
Examples
2098+
--------
2099+
>>> s = pd.Series([0, 1, 2, 3])
2100+
>>> other = pd.Series([-1, 2, -3, 4])
2101+
>>> s.dot(other)
2102+
8
2103+
>>> s @ other
2104+
8
2105+
>>> df = pd.DataFrame([[0 ,1], [-2, 3], [4, -5], [6, 7]])
2106+
>>> s.dot(df)
2107+
0 24
2108+
1 14
2109+
dtype: int64
2110+
>>> arr = np.array([[0, 1], [-2, 3], [4, -5], [6, 7]])
2111+
>>> s.dot(arr)
2112+
array([24, 14])
20762113
"""
20772114
from pandas.core.frame import DataFrame
20782115
if isinstance(other, (Series, DataFrame)):

0 commit comments

Comments
 (0)