-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
Changes from 13 commits
de49e43
839fafb
0cbbcde
1887872
c1fc307
ddc8bd8
1ea7d1d
20bea4e
8249829
292ba87
09b195a
bc3aa8d
0af57f1
756abdb
4229a70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6308,11 +6308,23 @@ def fillna( | |
else: | ||
if self.ndim == 1: | ||
if isinstance(value, (dict, ABCSeries)): | ||
value = create_series_with_explicit_dtype( | ||
value_map = create_series_with_explicit_dtype( | ||
value, dtype_if_empty=object | ||
) | ||
value = value.reindex(self.index, copy=False) | ||
value = value._values | ||
# GH#40498 objects can have multiple types of missing values which | ||
# should not be modified unless specified. Add special casing to | ||
# minimize performance decrease on other data types where this is | ||
# not required. | ||
if is_object_dtype(self.dtype): | ||
value = self.copy() | ||
modification_index = value.index.intersection(value_map.index) | ||
if not modification_index.empty: | ||
value.loc[modification_index] = value_map[ | ||
modification_index | ||
] | ||
else: | ||
value = value_map.reindex(self.index) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately the testing method we're using cannot differentiate the following:
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 commentThe 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 commentThe 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 commentThe 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? |
||
value = value._values | ||
elif not is_list_like(value): | ||
pass | ||
else: | ||
|
Uh oh!
There was an error while loading. Please reload this page.