I have a data frame with two columns of an index like this.
A B
one two three four
ID
A 0.895717 -1.206412 1.431256 -1.170299
B 0.410835 0.132003 -0.076467 1.130127
C -1.413681 1.024180 0.875906 0.974466
I want to filter it by first & second levels as mentioned below:
- I want to mention only the first level.
df[A]
A
one two
ID
A 0.895717 -1.206412
B 0.410835 0.132003
C -1.413681 1.024180
- I want to mention columns of second-level like this:
df[A[two],B[three,four]]
A B
ID two three four
A -1.206412 1.431256 -1.170299
B 0.132003 -0.076467 1.130127
C 1.024180 0.875906 0.974466
Kindly help!