Tutorials References Menu

Pandas DataFrame eq() Method

❮ DataFrame Reference


Example

Find which values are equal to 7:

import pandas as pd

df = pd.DataFrame([[10, 12, 2], [3, 4, 7]])

print(df.eq(7))
Try it Yourself »

Definition and Usage

The eq() method compares each value in a DataFrame to check if it is equal to a specified value, or a value from a specified DataFrame objects, and returns a DataFrame with boolean True/False for each comparison.


Syntax

dataframe.eq(other, axis, level)

Parameters

Parameter Description
other Required. A number, list of numbers, or another object with a data structure that fits with the original DataFrame.
axis Optional, A definition that decides whether to compare by index or columns.
0 or 'index' means compare by index.
1 or 'columns' means compare by columns
level Optional. A number or label that indicates where to compare.

Return Value

A DataFrame object.


❮ DataFrame Reference