Skip to content

BUG: pd.DataFrame.replace() with value=pd.NA in pandas v1.5.0 and v1.5.1 crushes python kernel #49439

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

Closed
3 tasks done
romanov-o opened this issue Nov 1, 2022 · 2 comments
Closed
3 tasks done
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@romanov-o
Copy link

Pandas version checks

  • 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.

Reproducible Example

import pandas as pd

pd.DataFrame([0,1,2,3]).replace(0, pd.NA)

Issue Description

pd.DataFrame.replace() with value=pd.NA in pandas v1.5.0 and v1.5.1 crushes python kernel:

RecursionError: maximum recursion depth exceeded while calling a Python object

Expected Behavior

      0
0    <NA>
1     1
2     2
3     3

Installed Versions

INSTALLED VERSIONS

commit : 91111fd
python : 3.10.0.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.17763
machine : AMD64
processor : Intel64 Family 6 Model 85 Stepping 7, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1251

pandas : 1.5.1
numpy : 1.21.4
pytz : 2021.3
dateutil : 2.8.2
setuptools : 57.4.0
pip : 22.3
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.0.3
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : 7.30.1
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.5.0
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None

@romanov-o romanov-o added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 1, 2022
@phofl
Copy link
Member

phofl commented Nov 1, 2022

Hi, thanks for your report.
Duplicate of #45725

@phofl phofl closed this as completed Nov 1, 2022
@gusutabopb
Copy link

@phofl This issue is still present in 1.5.2 (worked fine in 1.4.x):

pd.Series([0.0, 1.0]).replace(0.0, pd.NA)

throws

RecursionError: maximum recursion depth exceeded while calling a Python object

Current work around I found is to cast to object before replace:

pd.Series([0.0, 1.0]).astype(object).replace(0.0, pd.NA)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

3 participants