What is the dot method in pandas?

The dot method in pandas takes the dot product of a dataframe with another dataframe, series, or array-like object. The dot product is also known as matrix multiplication.

The shapes of both objects should be compatible with each other to calculate the dot product.

The illustration below shows how the dot product is computed:

How to calculate the dot product

Syntax

The syntax of the dot method is as follows:

Dataframe.dot(other)

Parameters

The dot method has a single parameter: other.

Other refers to a dataframe, series, or array-like object with which the dot product is taken.

Return value

The dot method returns a series if the other parameter is a series object.

It returns a dataframe if the other parameter is a dataframe.

Examples

The code snippet below shows how we can use the dot operator in pandas:

import pandas as pd
import numpy as np
# Dataframe with a series
df = pd.DataFrame([[0, 1, -2, -1], [1, 1, 1, 1]])
s = pd.Series([1, 1, 2, 1])
print("Dataframe with a series")
print(df.dot(s))
print('\n')
# Dataframe with another Dataframe
other = pd.DataFrame([[0, 1], [1, 2], [-1, -1], [2, 0]])
print("Dataframe with another Dataframe")
print(df.dot(other))
print('\n')
# Dataframe with an array
arr = np.array([[0, 1], [1, 2], [-1, -1], [2, 0]])
print("Dataframe with another array")
print(df.dot(arr))
print('\n')

The dot method is the same as the @ operator in pandas.

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved