2

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.

AliY
  • 557
  • 9
  • 27
  • Read the Pandas documentation. – AMC Feb 22 '20 at 18:58
  • Does this answer your question? [Selecting a row of pandas series/dataframe by integer index](https://stackoverflow.com/questions/16096627/selecting-a-row-of-pandas-series-dataframe-by-integer-index) – AMC Feb 22 '20 at 18:59

1 Answers1

4

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]
Valdi_Bo
  • 30,023
  • 4
  • 23
  • 41
  • sorry I explained my question wrong, I wanted to drop all rows after the 864000th row – AliY Feb 22 '20 at 17:54