-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DataFrame.replace with dict behaves inconsistently for integers and strings #20656
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
Comments
@Coldsp33d : That is weird indeed. PR to patch is welcome! |
Same problem happens in |
Yeah, that's fine. |
@Licht-T Is there an issue for |
@Licht-T I am working on this issue and I can solve for replace with string. Still, Regex replace is not solved. Maybe you can open another issue for regex replace. I think it takes more efforts to solve that. |
From SO
DataFrame.replace does not behave consistently when replacing integers vs replacing strings.
Reproducible example:
This yields the result:
However, when using the same commands for string values
This gives
But it should give
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.0.final.0
python-bits: 64
OS: Darwin
OS-release: 17.4.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.22.0
pytest: None
pip: 9.0.3
setuptools: 38.5.1
Cython: 0.28.1
numpy: 1.14.0
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2018.3
blosc: None
bottleneck: None
tables: None
numexpr: 2.6.4
feather: None
matplotlib: 2.1.2
openpyxl: None
xlrd: 0.9.4
xlwt: None
xlsxwriter: None
lxml: 3.8.0
bs4: 4.6.0
html5lib: 1.0b8
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: