Skip to content

Commit c1fc307

Browse files
author
Mike Phung
committed
BUG GH#40498 Add conditional for object dtype to avoid performance decrease.
1 parent 1887872 commit c1fc307

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pandas/core/generic.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6278,10 +6278,17 @@ def fillna(
62786278
value_map = create_series_with_explicit_dtype(
62796279
value, dtype_if_empty=object
62806280
)
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]
6281+
if self.dtype == "object":
6282+
value = self.copy()
6283+
modification_index = value.index.intersection(value_map.index)
6284+
if not modification_index.empty:
6285+
value.loc[modification_index] = value_map[
6286+
modification_index
6287+
]
6288+
else:
6289+
value = value_map
6290+
value = value.reindex(self.index, copy=False)
6291+
value = value._values
62856292
elif not is_list_like(value):
62866293
pass
62876294
else:

0 commit comments

Comments
 (0)