Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

I have a multi-index data frame with columns 'A' and 'B'.

Is there is a way to select rows by filtering on one column of the multi-index without resetting the index to a single column index?

For Example.

# has multi-index (A,B)

df

#can I do this? I know this doesn't work because the index is multi-index so I need to     specify a tuple

df.ix[df.A ==1]

1 Answer

0 votes
by (41.4k points)

Use DataFrame.loc:

>>> df.loc[1]

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...