Selecting Columns to Import from Excel Using Pandas


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
 3|  df = pd.read_excel('Returns.xlsx', 
 4|  		   sheet_name='Returns', 
 5|  		   usecols=['OrderNo','ProductID'])
Did you find this snippet useful?

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