python pandas 删除前几行 末尾几行

df.drop(df.tail(n).index) #从尾部去掉 n 行
df.dorp(df.head(n).index) #从头去掉 n 行
#可以加上 inplace=True 直接修改原 dataFrame,不过函数返回是 None
也可以这样子

PageDF = PageDF[:-1]

posted @ 2022-04-15 11:23  myrj  阅读(2869)  评论(0编辑  收藏  举报