python - Hierarchical indexing with Pandas -
i have pandas dataframe
with 3 index levels , 2 columns. can see part of here:
av_intensity std_dev key1 key2 time 0 0 32000 -0.005203 0.006278 32200 0.005330 0.005221 32400 0.002679 0.005006 32600 -0.000723 0.006145 32800 -0.000317 0.010467 33000 -0.006543 0.007808 33200 -0.004180 0.005070 33400 -0.006275 0.009662 33600 -0.014763 0.006938 33800 -0.029516 0.004710
the indices numbers, e.g. (0.0, 0, 32000.0)
set of indices.
i trying use df.ix[ 0.0, :, 32000.0]
or df.ix[ :, 0, 32000]
kind of hierarchical indexing doesn't work.
is because indices not integer?
how can kind of hierarchical indexing data frame?
see advanced hierarchical indexing section in docs full explanation: http://pandas.pydata.org/pandas-docs/dev/advanced.html#advanced-indexing-with-hierarchical-index
but basically, cannot use slices (:
) within multi-index key. can creating :
slice(none)
:
datagroupd.loc[(0.0, slice(none), 32000.0),:]
or use indexslice
convenience object lets write plain :
's:
idx = pd.indexslice datagroupd.loc[idx[0.0, :, 32000.0],:]
Comments
Post a Comment