pandas.Series.dot#

Series.dot(other)[源代码]#

计算级数和其他列之间的点积。

此方法计算序列与另一个序列、序列与DataFrame的每一列、序列与数组的每一列之间的点积。

也可以使用以下命令调用它 self @ other 在Python中>=3.5。

参数
other系列、DataFrame或类似数组

另一个对象是计算其列的点积。

退货
标量、级数或数字.ndarray

返回Series和Other的点积,如果Other是Series,则返回Series的点积的Series,如果Other是DataFrame或NumPy数组的每列之间的Numpy.ndarray,则返回Other的每一行。

参见

DataFrame.dot

用DataFrame计算矩阵乘积。

Series.mul

级数和其他元素的乘法。

注意事项

如果Other是Series或DataFrame,则Series和Other必须共享相同的索引。

示例

>>> s = pd.Series([0, 1, 2, 3])
>>> other = pd.Series([-1, 2, -3, 4])
>>> s.dot(other)
8
>>> s @ other
8
>>> df = pd.DataFrame([[0, 1], [-2, 3], [4, -5], [6, 7]])
>>> s.dot(df)
0    24
1    14
dtype: int64
>>> arr = np.array([[0, 1], [-2, 3], [4, -5], [6, 7]])
>>> s.dot(arr)
array([24, 14])