私はパンダが初めてで、MultiIndex'ed DataFrame からデータを抽出しようとしています
pandas で MultiIndex オブジェクトから値の範囲を選択することは可能ですか?たとえば、以下の DataFrame の例では、最初のレベル (bar、baz、foo & qux) および 'one' と 'すべての列の 2 番目のレベルから 2'。それは可能ですか?
arrays = [np.array(['bar', 'bar', 'bar', 'baz', 'baz', 'baz', 'foo', 'foo', 'foo', 'qux', 'qux','qux']),
np.array(['one', 'two','three','one', 'two', 'three','one', 'two','three', 'one', 'two','three'])]
df = pd.DataFrame(randn(12, 6), index=arrays)
0 1 2 3 4 5
bar one -0.031447 0.084358 -0.045284 -0.073702 -0.566905 -0.541734
two -0.381897 0.422047 -0.527828 0.419984 -0.920186 0.643190
three 0.082314 2.584901 1.149755 -0.741753 0.696301 -0.132365
baz one 0.637182 -0.210955 -0.329989 0.021509 -0.483201 -1.194727
two 3.602497 -0.010458 1.734119 -0.332384 0.135082 0.194316
three -0.293277 -0.144820 0.155034 -0.490092 -0.800939 -0.286902
foo one 1.244119 0.024739 0.500957 0.774194 -3.344261 1.098748
two -2.328298 -0.473493 0.881086 0.548408 0.882422 -0.151467
three 0.512852 1.687702 0.154186 -0.079843 0.116599 -1.330802