Pandas: Always selecting the first sheet/tab in an Excel Sheet
Solution 1
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
Solution 2
Also this bug at the time of writing: https://github.com/pandas-dev/pandas/issues/17107
Use 'sheetname', not 'sheet_name'.
Related videos on Youtube
Meghdeep Ray
Loved programming ever since I started at the age of 10. Love Python3, passionate about Artificial Intelligence, Machine Learning and Big Data Analytics. Completed my Undergraduate Degree in Computer Science and Engineering from PES University, Bangalore.
Updated on July 05, 2022Comments
-
Meghdeep Ray almost 2 years
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 ?
-
EdChum almost 9 years
-
EdChum almost 9 yearsYes, why don't you try it
-
-
Ben almost 6 yearsYou don't even need to pass the sheet name, you can simply leave out the
sheetname
orsheet_name
(the former is depreciated as of this writing) and it will take the first -
Erick about 4 yearsThanks @RGH !!! I was going crazy not knowing what I was doing wrong..