Skip to content

Commit 20bea4e

Browse files
author
Mike Phung
committed
BUG GH#40498 Add comment and cleanup logic for special case.
1 parent 1ea7d1d commit 20bea4e

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
@@ -6311,16 +6311,18 @@ def fillna(
63116311
value_map = create_series_with_explicit_dtype(
63126312
value, dtype_if_empty=object
63136313
)
6314-
if self.dtype == "object":
6314+
# GH#40498 objects can have multiple types of missing values which should not be modified unless
6315+
# specified. Add special casing to minimize performance decrease on other data types where this is
6316+
# not required.
6317+
if is_object_dtype(self.dtype):
63156318
value = self.copy()
63166319
modification_index = value.index.intersection(value_map.index)
63176320
if not modification_index.empty:
63186321
value.loc[modification_index] = value_map[
63196322
modification_index
63206323
]
63216324
else:
6322-
value = value_map
6323-
value = value.reindex(self.index, copy=False)
6325+
value = value_map.reindex(self.index, copy=False)
63246326
value = value._values
63256327
elif not is_list_like(value):
63266328
pass

0 commit comments

Comments
 (0)