Pandas Dataframe.dot()
works similarly to the mul ()
method, but instead of returning the multiplied individual values, the Dot product is returned (the sum of the multiplication of values for each index).
Syntax: Series.dot (other)
Parameters:
other: Other Series to be used to calculate DOT productReturn type: Series with updated values
Example # 1:
This example creates two series from Python lists using the Pandas Series ()
method. Then the method for series1 is called and series2 is passed as a parameter. The result is then stored in a variable and displayed.
|
Exit :
Dot product = 93
Explanation —
The items in the caller series are multiplied by the items with the same index in the skipped series. All of the multiplied values are then added to get the dot product.
As in the above example, the series:
[7, 5, 6, 4, 9] [1, 2, 3, 10, 2] Dot product = 7 * 1 + 5 * 2 + 6 * 3 + 4 * 10 + 9 * 2 = 7 + 10 + 18 + 40 + 18 = 93
Note. If there is any -or Null, the net result is NaN. NaN values should be dropped / replaced using fillna ()
respectively.