-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DataFrame.replace fails to replace value when columns are specified and only non-replacement columns contain pd.NA #32838
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
Labels
Comments
@jorisvandenbossche
The underlying cause might be the same, but contrary to those issues, there
are no missing values in the column where values are to be replaced.
…On Fri, Mar 20, 2020 at 7:22 PM Joris Van den Bossche < ***@***.***> wrote:
Thanks for the report!
Probably a duplicate of #32621
<#32621> or #32075
<#32075>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#32838 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTX3RGVWNOC4YON3FYLUVLRIOQ3VANCNFSM4LPVKNHQ>
.
|
I think @jorisvandenbossche is right. This seems to work fine since the this issue was fixed: #32621 >>> import pandas as pd
>>> import numpy as np
>>> df2 = pd.DataFrame([['a', 1], ['b', pd.NA]])
>>> df2.replace({0: 'a'}, np.nan)
0 1
0 NaN 1
1 b <NA> @tsoernes : Can you also confirm that? If that's the case, then I suggest we close this. Thanks! |
Your output is what is expected. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Code Sample, a copy-pastable example if possible
Problem description
There are multiple similar issues, but in this case, there are no NaNs in the column specified by the replacement-dictionary. If the dataframe is created without additional column
1
with apd.NA
, even though no replacement is performed on that column, then replace works.Expected Output
'a' to be replaced with nan
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: