Skip to content

Commit 651ac7d

Browse files
committed
feedback: collapse datetimelike if body
1 parent 45eef38 commit 651ac7d

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
@@ -170,17 +170,7 @@ def maybe_downcast_to_dtype(result, dtype):
170170
# a datetimelike
171171
# GH12821, iNaT is cast to float
172172
if dtype.kind in ["M", "m"] and result.dtype.kind in ["i", "f"]:
173-
174-
if is_datetime_or_timedelta_dtype(dtype):
175-
result = result.astype(dtype)
176-
else:
177-
# not a numpy dtype
178-
if dtype.tz:
179-
# convert to datetime and change timezone
180-
from pandas import to_datetime
181-
182-
result = to_datetime(result).tz_localize("utc")
183-
result = result.tz_convert(dtype.tz)
173+
result = result.astype(dtype)
184174

185175
return result
186176

0 commit comments

Comments
 (0)