Selecting Rows from a Pandas Dataframe Using iLoc

Python

In this code snippet we'll select the first 10 rows and then the last 10 rows from a dataframe.

 1|  #Select first 10 rows
 2|  
 3|  df.iloc[0:10,:]
 4|  
 5|  #Selecting last 10 rows
 6|  
 7|  df.iloc[-10:,:]
Did you find this snippet useful?

Sign up for free to to add this to your code library