Selecting the Number of Rows to Import from Excel Sheet with Pandas

Python
Import and Export

To select how many rows to import from an Excel sheet into a Pandas dataframe then pass the number using the "nrows" parameter. Note that Pandas will import whichever rows in encounters first.

For the example below, we are reading the first 500 rows from the Returns Excel sheet.

 1|  import pandas as pd
 2|  
 3|  df = pd.read_excel('Returns.xlsx', sheet_name='Returns', nrows=500)
1 Upvote
Tags: Read_excel | Excel
Did you find this snippet useful?

Sign up to bookmark this in your snippet library