PERF: .iloc[:, :len(columns)+1]
in case of multiple numeric blocks works much slower since pandas 2.1.0
#55202
Labels
Needs Triage
Issue that has not been reviewed by a pandas team member
Performance
Memory or execution speed performance
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this issue exists on the latest version of pandas.
I have confirmed this issue exists on the main branch of pandas.
Reproducible Example
Here in the reproducer, I'm splitting a dataframe into several even row chunks.
Case 1: I only pass a row indexer into
.iloc
(works fast).Case 2: I pass a row indexer and
slice(None)
as a column indexer to.iloc
. This overall shouldn't and doesn't change the result (also works fast).Case 3: I pass a row indexer and a full-axis slice as a column indexer to
.iloc
. In my understanding, this is not a big change compared with 'case 2' and 'case 1', since I still expect to get the same result, however, in this case, performance drops dramatically starting from pandas 2.1.0The problem is only reproducible with multiple number of numeric blocks, so I do columns concatenation beforehand in my reproducer.
Installed Versions
INSTALLED VERSIONS
commit : ba1cccd
python : 3.11.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.0-76-generic
Version : #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.1.0
numpy : 1.26.0
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.2.2
pip : 23.2.1
Cython : None
pytest : None
hypothesis : None
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 : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
(I verified that the numpy version was the same in both runs when I compared pandas 2.0.3 and 2.1.0)
Prior Performance
No response
The text was updated successfully, but these errors were encountered: