Alexis G
Alexis G

Reputation: 1339

Access two one index of multiindex DataFrame

I look for accessing to all elements where the second index equal 'P0 (YI)' but my command doesn't work. Can somebody help me ?

>>> G11
<class 'pandas.core.frame.DataFrame'>
MultiIndex: 10000 entries, (s0000, Averaging) to (s0999, P0 (YI))
Data columns (total 3 columns):
Volume    10000  non-null values
dtypes: float64(3)

>>> G11.ix[(:,'P0 (YI)')]
  File "<stdin>", line 1
    G11.ix[(:,'P0 (YI)')]
            ^
SyntaxError: invalid syntax

Upvotes: 0

Views: 94

Answers (2)

acushner
acushner

Reputation: 9946

try

G11.xs('P0 (YI)', level=1)

Upvotes: 0

Jeff
Jeff

Reputation: 128948

Use G11.xs('P0 (YI)',level=1)

The syntax that you are suggesting will be available in 0.14, see here

Upvotes: 2

Related Questions