Selecting Columns to Import from Excel Using Pandas
Python
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'])
149
132
127
119