PERF: performance regression in assigning value to df[col_name] · Issue #46267 · pandas-dev/pandas (original) (raw)

@Hubedge

Pandas version checks

Reproducible Example

import numpy as np import pandas as pd from tqdm import tqdm

df = pd.DataFrame(np.random.random((5000,15000))) df.columns = df.columns.astype("str") col_0_np = df.iloc[:, 0].to_numpy()

for idx in tqdm(df.columns): df[idx] = col_0_np

  0%|          | 20/15000 [00:04<57:50,  4.32it/s] 

Installed Versions

INSTALLED VERSIONS

commit : 06d2301
python : 3.8.12.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD
byteorder : little
LC_ALL : None
LANG : None
LOCALE : ***

pandas : 1.4.1
numpy : 1.19.2
pytz : 2021.3
dateutil : 2.8.2
pip : 21.2.2
setuptools : 58.0.4
Cython : None
pytest : 6.2.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.8.0
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.2
IPython : 7.31.1
pandas_datareader: None
bs4 : 4.8.0
bottleneck : 1.3.2
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.5.1
numba : 0.54.1
numexpr : 2.7.3
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.6.2
sqlalchemy : 1.4.27
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 2.0.1
xlwt : None
zstandard : None

Prior Performance

In 1.3.5, the code should complete within seconds.