File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 40
40
is_datetime64_dtype ,
41
41
is_datetime64_ns_dtype ,
42
42
is_datetime64tz_dtype ,
43
+ is_datetime_or_timedelta_any_dtype ,
43
44
is_datetime_or_timedelta_dtype ,
44
45
is_dtype_equal ,
45
46
is_extension_array_dtype ,
@@ -160,9 +161,9 @@ def maybe_downcast_to_dtype(result, dtype):
160
161
return converted
161
162
162
163
# a datetimelike
163
- # GH12821, iNaT is casted to float
164
- if dtype . kind in [ "M" , "m" ] and result .dtype .kind in ["i" , "f" ]:
165
- if hasattr (dtype , "tz" ):
164
+ # GH12821, iNaT is cast to float
165
+ if is_datetime_or_timedelta_any_dtype ( dtype ) and result .dtype .kind in ["i" , "f" ]:
166
+ if not is_datetime_or_timedelta_dtype (dtype ):
166
167
# not a numpy dtype
167
168
if dtype .tz :
168
169
# convert to datetime and change timezone
You can’t perform that action at this time.
0 commit comments