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 6b7d0d1 commit 8283e8aCopy full SHA for 8283e8a
pandas/core/dtypes/cast.py
@@ -185,17 +185,7 @@ def maybe_downcast_to_dtype(result, dtype: Dtype):
185
# a datetimelike
186
# GH12821, iNaT is cast to float
187
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)
+ result = result.astype(dtype)
199
200
return result
201
0 commit comments