Selecting Columns to Import from Excel Using Pandas

Python
Import and Export

To select which columns to import from an Excel sheet into a Pandas dataframe, simply pass a list of the required columns to the "usecols" parameter of read_excel.

In the example below we only want to import the "OrderNo" and "ProductID" columns from the Returns sheet.

 1|  import pandas pd
 2|  
 3|  df = pd.read_excel('Returns.xlsx', 
 4|  		   sheet_name='Returns', 
 5|  		   usecols=['OrderNo','ProductID'])
1 Upvote
Tags: Read_excel | Excel
Did you find this snippet useful?

Sign up to bookmark this in your snippet library