Skip to content

Commit 1724acb

Browse files
committed
feedback: revert datetimelike block
1 parent 4d4066a commit 1724acb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pandas/core/dtypes/cast.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,16 @@ 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-
if is_datetime_or_timedelta_dtype(dtype):
189-
result = result.astype(dtype)
190-
else:
188+
if hasattr(dtype, "tz"):
191189
# not a numpy dtype
192190
if dtype.tz:
193191
# convert to datetime and change timezone
194192
from pandas import to_datetime
195193

196194
result = to_datetime(result).tz_localize("utc")
197195
result = result.tz_convert(dtype.tz)
196+
else:
197+
result = result.astype(dtype)
198198

199199
return result
200200

0 commit comments

Comments
 (0)