简体   繁体   中英

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.

Thank you.

One of possible solutions is to use iloc :

n = 864000
df.iloc[:n]

The above code retrieves initial n rows (for now df holds all rows). But if you want to drop all rows beyond this limit, run:

df = df.iloc[:n]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM