Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame({'cost': [200, 150, 100],
                   'revenue': [100, 200, 250]},
                  index=['P', 'Q', 'R'])
df
Out[2]:
cost revenue
P 200 100
Q 150 200
R 100 250

Compare to a MultiIndex by level:

In [3]:
df_multindex = pd.DataFrame({'cost': [200, 150, 100, 150, 250, 120],
                             'revenue': [100, 200, 250, 180, 155, 125]},
                            index=[['A1', 'A1', 'A1', 'A2', 'A2', 'A2'],
                                   ['P', 'Q', 'R', 'P', 'Q', 'R']])
df_multindex
Out[3]:
cost revenue
A1 P 200 100
Q 150 200
R 100 250
A2 P 150 180
Q 250 155
R 120 125
In [4]:
df.le(df_multindex, level=1)
Out[4]:
cost revenue
A1 P True True
Q True True
R True True
A2 P False True
Q True False
R True False