Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame({'cost': [350, 250, 200],
                   'revenue': [200, 350, 400]},
                  index=['M', 'N', 'O'])
df
Out[2]:
cost revenue
M 350 200
N 250 350
O 200 400

Comparison with a scalar, using either the operator or method:

In [3]:
df == 200
Out[3]:
cost revenue
M False True
N False False
O True False
In [4]:
df.eq(200)
Out[4]:
cost revenue
M False True
N False False
O True False

When comparing to an arbitrary sequence, the number of columns must match the number
elements in other:

In [5]:
df == [350, 200]
Out[5]:
cost revenue
M True True
N False False
O False False

Use the method to control the axis:

In [6]:
df.eq([350, 350, 200], axis='index')
Out[6]:
cost revenue
M True False
N False True
O True False