Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
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
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.6k users

Browse Categories

...