Pandas DataFrame dot() Method
Multiply values from one DataFrame with values from another DataFrame, and add them together:
df1 = pd.DataFrame([[1, 2], [3, 4]])
df2 = pd.DataFrame([[5, 6], [7, 8]])
Definition and Usage
dot() method multiplies each value from
one DataFrame with the values from another DataFrame (or Series or array), and
adds them together.
Assume you have these two DataFrame objects:
[[5, 6], [7, 8]]
Multiply the values from the first DataFrame with the values from the second DataFrame, one by one like this:
2 * 7 = 14
Summarize the two products:
19 will be the first value in the result.
Here you can see the calculation for each value in the result:
(1 * 6) + (2 * 8) = 22
(3 * 5) + (4 * 7) = 43
(3 * 6) + (4 * 8) = 50
which will result in a DataFrame object like this::
|other||Required. A number, list of numbers, or another object with a data structure that fits with the original DataFrame.|
A DataFrame with the results.