Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.

Examples
Multiply a DataFrame with a Series:

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame([[0, 2, -1, -2], [2, 2, 2, 2]])
s = pd.Series([2, 1, 2, 1])
df.dot(s)
Out[2]:
0    -2
1    12
dtype: int64

Multiply a DataFrame with another DataFrame:

In [3]:
other = pd.DataFrame([[0, 2], [1, 2], [-2, -1], [2, 0]])
df.dot(other) 
Out[3]:
0 1
0 0 5
1 2 6

The dot method give the same result as @:

In [4]:
df @ other
Out[4]:
0 1
0 0 5
1 2 6

The dot method works also if other is an np.array:

In [5]:
arr = np.array([[0, 2], [1, 2], [-2, -1], [2, 0]])
df.dot(arr) 
Out[5]:
0 1
0 0 5
1 2 6

Shuffling of the objects does not change the result:

In [6]:
s2 = s.reindex([2, 0, 1, 3])
df.dot(s2)
Out[6]:
0    -2
1    12
dtype: int64