[英]How to select certain number of rows in data frame?
So I have a dataframe that is (2624229, 574) and I would like to select only the first 864000 rows, but I can't figure out how to do it.所以我有一个 (2624229, 574) 的数据框,我只想选择前 864000 行,但我不知道该怎么做。
Thank you.谢谢你。
One of possible solutions is to use iloc :一种可能的解决方案是使用iloc :
n = 864000
df.iloc[:n]
The above code retrieves initial n rows (for now df holds all rows).上面的代码检索初始n行(现在df保存所有行)。 But if you want to drop all rows beyond this limit, run:但是,如果您想删除超出此限制的所有行,请运行:
df = df.iloc[:n]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.