-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG GH#40498 Fillna other missing values not modified #42981
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
Conversation
ghost
commented
Aug 11, 2021
- closes BUG: Series.fillna is altering None values of unspecified columns #40498
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
Should be noted that these tests will not fail, even without my changes, because of an open issue - #18463. |
Hello @mikephung122! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-09-30 05:15:10 UTC |
pandas/core/generic.py
Outdated
modification_index | ||
] | ||
else: | ||
value = value_map.reindex(self.index, copy=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why can't you just set copy=True
for object type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the original logic that was present for all value dictionaries before I added the separate object type conditional.
I'm not sure why they chose to explicitly set copy=False since in both the old and new code we're replacing value with the reindexed version and the original value is not used anywhere else. In addition, unless every index is a key in the value dictionary I believe this will have no effect because - "A new object is produced unless the new index is equivalent to the current one and copy=False".
Will remove the unnecessary argument and return to the default since there's no clear value for it.
modification_index | ||
] | ||
else: | ||
value = value_map.reindex(self.index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you don't add the copy does this just work e.g. do you still need L6314-6325
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the testing method we're using cannot differentiate the following:
result = pd.Series([1, None, 3, "four"])
expected = pd.Series([1, np.nan, 3, "four"])
tm.assert_equal(result, expected)
If you remove L6314-6325 the unit tests will pass but the original problem will still exist. I mentioned this on my initial Pull Request but these tests will not fail because of an open issue - #18463. I probably should've clarified if it's worth writing tests with other bugs in mind, or to write them as if the bug will be fixed eventually.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.reindex should just work here. I am really not sure what you are trying to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you update here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jreback Sorry I might not be following, what did you want me to update here?