A B C D E
0 1.0 2013-01-02 1.0 1 test
1 1.0 2014-01-02 1.0 2 car
2 1.0 2015-01-02 1.0 3 tested
3 1.0 2016-01-02 1.0 4 train
我如何根据 E 列中的值对 pandas 数据帧进行切片以包含上面的三个连续行,例如从“测试”到“测试”?
请您参考如下方法:
IIUC,使用pd.DataFrame.iloc:
df.iloc[0:3]
A B C D E
0 1.0 2013-01-02 1.0 1 test
1 1.0 2014-01-02 1.0 2 car
2 1.0 2015-01-02 1.0 3 tested
