I have a dataframe with 100 columns and I want to select list of variables
ID A B C
0 day1 day10 Δday day1 day10 Δday day1 day10 Δday
1 1 1.0 2.0 1.0 1.5 2.5 1.0 3.0 2.0 -1.0
2 2 3.0 5.0 2.0 1.0 2.5 1.5 3.0 5.0 2.0
3 3 2.5 3.5 1.0 1.5 2.9 1.4 3.5 4.0 0.5
............................................................
............................................................
How do I filter which should yield the output as:
A B C
Δday Δday Δday
1.0 1.0 -1.0
2.0 1.5 2.0
1.0 1.4 0.5
I looked at Pandas' documentation and tried filter regex, iloc but did not succeed.
Try slice(None)
to select any column at first level:
>>> df.loc[:, (slice(None), 'Δday')]
A B C
Δday Δday Δday
0 1.0 1.0 -1.0
1 2.0 1.5 2.0
2 1.0 1.4 0.5
To know more: Using slicers
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.