Skip to content

Commit 0cbbcde

Browse files
author
Mike Phung
committed
BUG GH#40498 Create fillna values to use original mapped by new values.
1 parent 839fafb commit 0cbbcde

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pandas/core/generic.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6275,11 +6275,13 @@ def fillna(
62756275
else:
62766276
if self.ndim == 1:
62776277
if isinstance(value, (dict, ABCSeries)):
6278-
value = create_series_with_explicit_dtype(
6278+
value_map = create_series_with_explicit_dtype(
62796279
value, dtype_if_empty=object
62806280
)
6281-
value = value.reindex(self.index, copy=False)
6282-
value = value._values
6281+
value = self.copy()
6282+
modification_index = value.index.intersection(value_map.index)
6283+
if not modification_index.empty:
6284+
value.loc[modification_index] = value_map[modification_index]
62836285
elif not is_list_like(value):
62846286
pass
62856287
else:

0 commit comments

Comments
 (0)