pandas.Series.dot#
- Series.dot(other)[源代码]#
计算 Series 和 other 列之间的点积。
此方法计算 Series 与另一个 Series 之间的点积,或 Series 与 DataFrame 的每列之间的点积,或 Series 与数组的每列之间的点积。
也可以使用 self @ other 来调用。
- Parameters:
- otherSeries、DataFrame 或类数组对象
用于计算其列的点积的另一个对象。
- Returns:
- float, Series 或 numpy.ndarray
如果 other 是 Series,则返回 Series 与 other 的点积;如果 other 是 DataFrame 或 numpy.ndarray,则返回 Series 与 other 的每一行的点积的 Series,或者 Series 与 numpy 数组的每一列的点积。
参见
DataFrame.dot计算与 DataFrame 的矩阵乘积。
Series.mulSeries 和 other 的逐元素乘法。
Notes
如果 other 是 Series 或 DataFrame,则 Series 和 other 必须共享相同的索引。
Examples
>>> 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])