I\'ve started using Pandas for some large Datasets and mostly it works really well. There are some questions I have regarding the indices though
I have a MultiI
Edit: This answer for pandas versions lower than 0.10.0 only:
Okay @hayden had the right idea to start with:
An index has the method get_level_values()
which returns, however, an array (in pandas versions < 0.10.0). The isin()
method doesn't exist for arrays but this works:
from pandas import lib
lib.ismember(df.index.get_level_values('a'), set([5, 7, 10, 13])
That only answers question 1 - but I'll give an update if I crack 2, 3 (half done with @hayden's help)
For the first part, you can use boolean indexing using get_level_values:
df[df.index.get_level_values('a').isin([5, 7, 10, 13])]
For the second two, you can inspect the MultiIndex object by calling:
df.index
(and this can be inspected/sliced.)