[PYTHON] Excel sheet cannot be specified in sheet_name of pd.read_excel

The read_excel function used when reading data from Excel as a DataFrame, As mentioned in the reference, even if you specify the sheet name with sheet_name, no error occurs, but sometimes the sheet could not be acquired correctly. (No matter how I specified it, I could only get the first sheet)

import pandas as pd  #version 0.20.0
df = pd.read_excel(input_path, sheet_name="Sheet2") #I want to load the second sheet
print(df) #For some reason the contents of the first sheet come out

Apparently, sheet_name doesn't work in the environment of ** pandas 0.20 or earlier ** and it is correct to specify it by sheetname (why sheet_name can also be used as a keyword ...) By the way, in pandas 0.23, when I use sheetname, a warning is displayed, but both sheetname and sheet_name work. In the latest version, the sheetname keyword has already been deleted and only the sheet_name keyword can be used.

df = pd.read_excel(input_path, sheetname="Sheet2") #Sheetname without hyphens
print(df) #I got the second sheet properly

Recommended Posts

Excel sheet cannot be specified in sheet_name of pd.read_excel
Django cannot be installed in the development environment of pipenv + pyenv
De-VBA Excel tool! Eliminate VBA tool with Python in environment where Python cannot be installed
Summary of examples that cannot be pyTorch backward
[Django] css in the project cannot be read
Matplotlib etc. cannot be imported in VirtualEnv environment
Summary of Excel operations using OpenPyXL in Python
Patterns that files generated by OpenPyXl cannot be opened in Excel and their countermeasures
Output the specified table of Oracle database in Python to Excel for each file