We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 45eef38 commit 651ac7dCopy full SHA for 651ac7d
pandas/core/dtypes/cast.py
@@ -170,17 +170,7 @@ def maybe_downcast_to_dtype(result, dtype):
170
# a datetimelike
171
# GH12821, iNaT is cast to float
172
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)
+ result = result.astype(dtype)
184
185
return result
186
0 commit comments