Pandas: Always selecting the first sheet/tab in an Excel Sheet

Meghdeep Ray picture Meghdeep Ray · May 27, 2015 · Viewed 12.9k times · Source

I know how to get the list of sheet names. The excel file I am using has multiple sheets. How do I select the first one sequentially ? I don't know the name of the sheet but I need to select the first one. How would I go about this ?

Answer

Meghdeep Ray picture Meghdeep Ray · May 27, 2015

The first sheet is automatically selected when the Excel table is read into a dataframe.

To be explicit however, the command is :

import pandas as pd
fd = 'file path'
data = pd.read_excel( fd, sheet_name=0 )

Use of 'sheetname' is deprecated. Please use sheet_name