I was wondering if there is a clean way to select or subset a multi-index based Pandas data frame. My data looks like this (id and date - index):
values
id date
10113 2010-07-21 24.7000
2010-07-22 25.2600
2010-07-23 25.2800
2010-07-26 25.3700
2010-07-27 25.2900
10223 2011-07-21 24.7000
2011-07-22 25.2600
2011-07-23 25.2800
2011-07-26 25.3700
2011-07-27 25.2900
I need something like this:
df.xs[10223).xs('2011-07-21':'2011-07-30')
but the above code does not work for the second xs(). xs()can select only one row, not a subset of the data. I also tried df.query()and df.ix()but no luck.
Thank you for your help!
source
share