删除 pandas 中数据框的前三行 [英] Delete the first three rows of a dataframe in pandas
本文介绍了删除 pandas 中数据框的前三行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要删除熊猫中数据框的前三行.
I need to delete the first three rows of a dataframe in pandas.
我知道df.ix[:-1]
会删除最后一行,但是我不知道如何删除前n行.
I know df.ix[:-1]
would remove the last row, but I can't figure out how to remove first n rows.
推荐答案
使用 iloc
:
df = df.iloc[3:]
将为您提供一个没有前三行的新df.
will give you a new df without the first three rows.
这篇关于删除 pandas 中数据框的前三行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文