Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: df[col].replace(dict, inplace=True) is brutally slow, while .apply which does the same is blazing fast #7377

Open
2 of 3 tasks
Liquidmasl opened this issue Aug 27, 2024 · 0 comments
Labels
bug 🦗 Something isn't working Triage 🩹 Issues that need triage

Comments

@Liquidmasl
Copy link

Modin version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest released version of Modin.

  • I have confirmed this bug exists on the main branch of Modin. (In order to do this you can follow this guide.)

Reproducible Example

# create somewhat large dataframe, partition it into ~25 parts

df = pd.DataFrame({
    'val': np.random.randint(1, 10001, size=20_000_000)
})

unique = orig_with_hashes['df'].unique()
hash_map = {hash_: i for i, hash_ in enumerate(unique_hashes)}

# fast:
# df['val'] = df['val'].apply(lambda x: hash_map[x])

# slow:
df['val'].replace(hash_map, in_place=True)

Issue Description

replace method seams unreasonably slow.

Expected Behavior

should be faster

Error Logs

Replace this line with the error backtrace (if applicable).

Installed Versions

INSTALLED VERSIONS

commit : 52fca1c
python : 3.11.9.final.0
python-bits : 64
OS : Linux
OS-release : 6.8.0-40-generic
Version : #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
Modin dependencies

modin : 0.30.1
ray : 2.24.0
dask : 2024.6.0
distributed : 2024.6.0
hdk : None
pandas dependencies

pandas : 2.2.2
numpy : 1.26.3
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 69.5.1
pip : 24.1.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.3
IPython : 8.25.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.2.0
gcsfs : None
matplotlib : 3.8.4
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 16.1.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.14.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None

@Liquidmasl Liquidmasl added bug 🦗 Something isn't working Triage 🩹 Issues that need triage labels Aug 27, 2024
@github-staff github-staff deleted a comment from Liquidmasl Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🦗 Something isn't working Triage 🩹 Issues that need triage
Projects
None yet
Development

No branches or pull requests

2 participants
@Liquidmasl and others