I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
import tempfile import pandas as pd from pandas.testing import assert_frame_equal source_df = pd.DataFrame([{"row": 0}, {"row": 1}, {"row": 2}, {"row": 3}]) with tempfile.NamedTemporaryFile("w", suffix=".xlsx") as xlsx_fd: source_df.to_excel(xlsx_fd.name, index=False) df = pd.read_excel( xlsx_fd.name, skiprows=lambda x: x not in [0, 2] ) # infinite loop here expected_df = pd.DataFrame([{"row": 1}, {"row": 3}]) assert_frame_equal(df, expected_df)Issue Description
In certain cases the skiprows
callable on read_excel
will loop infinitely. It's related to the sequence of True
and False
values coming out of the function. I've already written a unit test that triggers the issue and a fix to address it. Creating this bug to track the fix against.
The test provided above should pass, where currently it will loop forever.
To put it another way; skiprows
callable should never be called with a row index that is greater than the length of the document.
commit : 04f5721
python : 3.9.9.final.0
python-bits : 64
OS : Darwin
OS-release : 21.2.0
Version : Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 1.5.0.dev0+130.g04f5721617
numpy : 1.22.1
pytz : 2021.3
dateutil : 2.8.2
pip : 21.2.4
setuptools : 58.1.0
Cython : 0.29.26
pytest : 6.2.5
hypothesis : 6.36.0
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : 1.2.1
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 2.0.1
xlwt : None
zstandard : None
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4