Reputation: 557
I have a pandas dataframe like this, where native-country
and salary
are indices. And I'd like to know, is it possible to access a a single row by native-country
, for instance by Canada
?
Upvotes: 1
Views: 106
Reputation: 18647
IIUC you can use DataFrame.xs
(cross-section)
df.xs(key='Canada', level=0, drop_level=False)
Upvotes: 1