In [2]:
import pandas as pd
import io

In [4]:
data = io.StringIO('''Fruit,Color,Count,Price
Apple,Red,3,$1.29
Apple,Green,9,$0.99
Pear,Red,25,$2.59
Pear,Green,26,$2.79
Lime,Green,99,$0.39
''')
df_unindexed = pd.read_csv(data)
df_unindexed


Out[4]:
Fruit Color Count Price
0 Apple Red 3 $1.29
1 Apple Green 9 $0.99
2 Pear Red 25 $2.59
3 Pear Green 26 $2.79
4 Lime Green 99 $0.39

In [5]:
df = df_unindexed.set_index(['Fruit', 'Color'])
df


Out[5]:
Count Price
Fruit Color
Apple Red 3 $1.29
Green 9 $0.99
Pear Red 25 $2.59
Green 26 $2.79
Lime Green 99 $0.39

In [6]:
df.xs('Apple')


Out[6]:
Count Price
Color
Red 3 $1.29
Green 9 $0.99