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=['P', 'Q', 'R'])
df
Out[2]:
cost revenue
P 350 200
Q 250 350
R 200 400

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

In [3]:
df == 200
Out[3]:
cost revenue
P False True
Q False False
R True False
In [4]:
df.lt(200)
Out[4]:
cost revenue
P False False
Q False False
R False False

Compare to a MultiIndex by level:

In [5]:
df_multindex = pd.DataFrame({'cost': [350, 250, 200, 250, 400, 330],
                             'revenue': [200, 350, 400, 300, 285, 335]},
                            index=[['A1', 'A1', 'A1', 'A2', 'A2', 'A2'],
                                   ['P', 'Q', 'R', 'P', 'Q', 'R']])
df_multindex
Out[5]:
cost revenue
A1 P 350 200
Q 250 350
R 200 400
A2 P 250 300
Q 400 285
R 330 335
In [6]:
df.lt(df_multindex, level=1)
Out[6]:
cost revenue
A1 P False False
Q False False
R False False
A2 P False True
Q True False
R True False