File tree Expand file tree Collapse file tree 2 files changed +3
-8
lines changed Expand file tree Collapse file tree 2 files changed +3
-8
lines changed Original file line number Diff line number Diff line change 1212from pandas ._libs .tslibs import (
1313 NaT ,
1414 OutOfBoundsDatetime ,
15+ Period ,
1516 Timedelta ,
1617 Timestamp ,
1718 iNaT ,
4041 is_datetime64_dtype ,
4142 is_datetime64_ns_dtype ,
4243 is_datetime64tz_dtype ,
43- is_datetime_or_timedelta_any_dtype ,
4444 is_datetime_or_timedelta_dtype ,
4545 is_dtype_equal ,
4646 is_extension_array_dtype ,
5050 is_integer_dtype ,
5151 is_numeric_dtype ,
5252 is_object_dtype ,
53- is_period_dtype ,
5453 is_scalar ,
5554 is_sparse ,
5655 is_string_dtype ,
@@ -132,7 +131,7 @@ def maybe_downcast_to_dtype(result, dtype):
132131 elif isinstance (result , ABCDataFrame ):
133132 # occurs in pivot_table doctest
134133 return result
135- elif is_period_dtype ( dtype ) :
134+ elif dtype . type is Period :
136135 from pandas .core .arrays import PeriodArray
137136
138137 with suppress (TypeError ):
@@ -169,7 +168,7 @@ def maybe_downcast_to_dtype(result, dtype):
169168
170169 # a datetimelike
171170 # GH12821, iNaT is cast to float
172- if is_datetime_or_timedelta_any_dtype ( dtype ) and result .dtype .kind in ["i" , "f" ]:
171+ if dtype . kind in [ "M" , "m" ] and result .dtype .kind in ["i" , "f" ]:
173172
174173 if is_datetime_or_timedelta_dtype (dtype ):
175174 result = result .astype (dtype )
Original file line number Diff line number Diff line change @@ -1067,10 +1067,6 @@ def is_datetime_or_timedelta_dtype(arr_or_dtype) -> bool:
10671067 return _is_dtype_type (arr_or_dtype , classes (np .datetime64 , np .timedelta64 ))
10681068
10691069
1070- def is_datetime_or_timedelta_any_dtype (arr_or_dtype ):
1071- return is_datetime64_any_dtype (arr_or_dtype ) or is_timedelta64_dtype (arr_or_dtype )
1072-
1073-
10741070# This exists to silence numpy deprecation warnings, see GH#29553
10751071def is_numeric_v_string_like (a , b ):
10761072 """
You can’t perform that action at this time.
0 commit comments