-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Replace methods fills value from previous row when replacing with None #33298
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
@DataSolveProblems Thanks for the report. I can confirm that the issue persists on master '1.1.0.dev0+1113.g8415f9ba2' |
I think the more idiomatic way would be to use DataFrame.fillna here, but that would raise |
I was able to workaround by passing a dictionary. Not ideal, but works. print(df.replace({np.NaN: None})) |
The issue occurs with other missing values not present in the DataFrame..
|
from the examples in https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.replace.html, it looks like this maybe expected behaviour as the default value for This issue also looks like a duplicate of #19998, so closing. ping to reopen if I missed something. |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Problem description
When replacing NaN with None using replace method, value, NaN value is replaced with value from previous row instead of None.
Expected Output
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: