File tree 2 files changed +3
-8
lines changed
2 files changed +3
-8
lines changed Original file line number Diff line number Diff line change 23
23
from pandas ._libs .tslibs import (
24
24
NaT ,
25
25
OutOfBoundsDatetime ,
26
+ Period ,
26
27
Timedelta ,
27
28
Timestamp ,
28
29
conversion ,
53
54
is_datetime64_dtype ,
54
55
is_datetime64_ns_dtype ,
55
56
is_datetime64tz_dtype ,
56
- is_datetime_or_timedelta_any_dtype ,
57
57
is_datetime_or_timedelta_dtype ,
58
58
is_dtype_equal ,
59
59
is_extension_array_dtype ,
63
63
is_integer_dtype ,
64
64
is_numeric_dtype ,
65
65
is_object_dtype ,
66
- is_period_dtype ,
67
66
is_scalar ,
68
67
is_sparse ,
69
68
is_string_dtype ,
@@ -147,7 +146,7 @@ def maybe_downcast_to_dtype(result, dtype: Dtype):
147
146
elif isinstance (result , ABCDataFrame ):
148
147
# occurs in pivot_table doctest
149
148
return result
150
- elif is_period_dtype ( dtype ) :
149
+ elif dtype . type is Period :
151
150
from pandas .core .arrays import PeriodArray
152
151
153
152
with suppress (TypeError ):
@@ -184,7 +183,7 @@ def maybe_downcast_to_dtype(result, dtype: Dtype):
184
183
185
184
# a datetimelike
186
185
# GH12821, iNaT is cast to float
187
- if is_datetime_or_timedelta_any_dtype ( dtype ) and result .dtype .kind in ["i" , "f" ]:
186
+ if dtype . kind in [ "M" , "m" ] and result .dtype .kind in ["i" , "f" ]:
188
187
189
188
if is_datetime_or_timedelta_dtype (dtype ):
190
189
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:
1067
1067
return _is_dtype_type (arr_or_dtype , classes (np .datetime64 , np .timedelta64 ))
1068
1068
1069
1069
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
-
1074
1070
# This exists to silence numpy deprecation warnings, see GH#29553
1075
1071
def is_numeric_v_string_like (a , b ):
1076
1072
"""
You can’t perform that action at this time.
0 commit comments