Skip to content

Commit 846c5aa

Browse files
authored
PERF: Improve performance for fillna with datetime (#57479)
* PERF: Improve performance for fillna with datetime * Update
1 parent e62746a commit 846c5aa

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pandas/core/arrays/datetimelike.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ def _validation_error_message(self, value, allow_listlike: bool = False) -> str:
649649

650650
def _validate_listlike(self, value, allow_object: bool = False):
651651
if isinstance(value, type(self)):
652-
if self.dtype.kind in "mM" and not allow_object:
652+
if self.dtype.kind in "mM" and not allow_object and self.unit != value.unit: # type: ignore[attr-defined]
653653
# error: "DatetimeLikeArrayMixin" has no attribute "as_unit"
654654
value = value.as_unit(self.unit, round_ok=False) # type: ignore[attr-defined]
655655
return value

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6958,7 +6958,7 @@ def fillna(
69586958
"with dict/Series column "
69596959
"by column"
69606960
)
6961-
result = self.copy(deep=False)
6961+
result = self if inplace else self.copy(deep=False)
69626962
for k, v in value.items():
69636963
if k not in result:
69646964
continue

0 commit comments

Comments
 (0)