Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[X] I have confirmed this bug exists on the [main branch] (https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas.
Reproducible Example
pandas.read_excel(fp, sheet_name="i_dont_exist")
Issue Description
When doing pandas.read_excel(fp, sheet_name="i_dont_exist")
with a sheet name that is not in the exel file the result is an empty data frame.
Expected Behavior
But there should be an error or FileNotFound exception.
Installed Versions
pandas.show_versions() [DEBUG] matplotlib data path: C:\Users\buhtzch\AppData\Roaming\Python\Python310\site-packages\matplotlib\mpl-data [DEBUG] CONFIGDIR=C:\Users\buhtzch.matplotlib [DEBUG] interactive is False [DEBUG] platform is win32
INSTALLED VERSIONS
commit : 8dab54d6573f7186ff0c3b6364d5e4dd635ff3e7 python : 3.10.2.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.19043 machine : AMD64 processor : Intel64 Family 6 Model 140 Stepping 1, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : de_DE.cp1252
pandas : 1.5.2 numpy : 1.23.5 pytz : 2022.6 dateutil : 2.8.2 setuptools : 58.1.0 pip : 22.3.1 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : 4.9.2 html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : None pandas_datareader: None bs4 : None bottleneck : None brotli : None fastparquet : None fsspec : None gcsfs : None matplotlib : 3.6.2 numba : None numexpr : None odfpy : None openpyxl : 3.0.10 pandas_gbq : None pyarrow : None pyreadstat : None pyxlsb : None s3fs : None scipy : 1.9.3 snappy : None sqlalchemy : None tables : None tabulate : 0.9.0 xarray : None xlrd : None xlwt : None zstandard : None tzdata : 2022.7
Comment From: dicristina
I cannot reproduce this with openpyxl nor with xlrd. I always get ValueError
when sheet_name
is not one of the sheets of the file.