Skip to content

Commit

Permalink
feedback: revert datetimelike block
Browse files Browse the repository at this point in the history
  • Loading branch information
arw2019 committed Oct 15, 2020
1 parent 4d4066a commit 1724acb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,16 @@ def maybe_downcast_to_dtype(result, dtype: Dtype):
# a datetimelike
# GH12821, iNaT is cast to float
if dtype.kind in ["M", "m"] and result.dtype.kind in ["i", "f"]:
if is_datetime_or_timedelta_dtype(dtype):
result = result.astype(dtype)
else:
if hasattr(dtype, "tz"):
# not a numpy dtype
if dtype.tz:
# convert to datetime and change timezone
from pandas import to_datetime

result = to_datetime(result).tz_localize("utc")
result = result.tz_convert(dtype.tz)
else:
result = result.astype(dtype)

return result

Expand Down

0 comments on commit 1724acb

Please sign in to comment.