简体   繁体   English

如何在数据框中选择一定数量的行?

[英]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.

相关问题 如何通过将一定数量的行附加到列表来对系列数据框进行分组? - How to group a series data frame by appending a certain number of rows to a list? 如何根据某些条件删除数据框中的重复行? - How to drop duplicated rows in data frame based on certain criteria? 如何将 Pandas 数据框中的某些行转换为列 - How to Convert certain rows in a Pandas Data frame to Columns 如果 pandas 数据帧的计数很小,如何删除某些行 - How to remove certain rows from pandas data frame if the counts of it is small 如何为满足特定条件的数据框的行赋值? - How to assign values to the rows of a data frame which satisfy certain conditions? 如何 append 数据帧的所有行的某些列到另一个 - How to append certain columns of all rows of data frame to another 如何根据数据框中的条件 select 某些值? - How to select certain values based on a condition in a data frame? 在熊猫数据框中的特定行数后,日期格式变回以前的格式 - The date format changes back to previous one after a certain number of rows in pandas data frame 使用pandas / python在数据框中出现列值小于某个数字时删除行? - Remove rows when the occurrence of a column value in the data frame is less than a certain number using pandas/python? 根据时间过滤数据框中的某些行 - Filter certain rows in data frame based on time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM