Skip to content

Commit e0ad0c4

Browse files
committed
feedback: collapse datetimelike if body
1 parent 05b5761 commit e0ad0c4

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

pandas/core/dtypes/cast.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,7 @@ def maybe_downcast_to_dtype(result, dtype: Dtype):
185185
# a datetimelike
186186
# GH12821, iNaT is cast to float
187187
if dtype.kind in ["M", "m"] and result.dtype.kind in ["i", "f"]:
188-
189-
if is_datetime_or_timedelta_dtype(dtype):
190-
result = result.astype(dtype)
191-
else:
192-
# not a numpy dtype
193-
if dtype.tz:
194-
# convert to datetime and change timezone
195-
from pandas import to_datetime
196-
197-
result = to_datetime(result).tz_localize("utc")
198-
result = result.tz_convert(dtype.tz)
188+
result = result.astype(dtype)
199189

200190
return result
201191

0 commit comments

Comments
 (0)