- Splitting
用布尔变量切割一个DataFrame
import pandas as pd
import numpy as np
df=pd.DataFrame({'AAA':[4,5,6,7],'BBB':[10,20,30,40],'CCC':[10,50,-30,-50]})
df
AAA | BBB | CCC | |
---|---|---|---|
0 | 4 | 10 | 10 |
1 | 5 | 20 | 50 |
2 | 6 | 30 | -30 |
3 | 7 | 40 | -50 |
dflow=df[df.AAA<=5]
dfhigh=df[df.AAA>5]
dfhigh
AAA | BBB | CCC | |
---|---|---|---|
0 | 4 | 10 | 10 |
1 | 5 | 20 | 50 |
splitting!DataFrame只显示了AAA大于等于5的那一部分