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 12
12
from pandas ._libs .tslibs import (
13
13
NaT ,
14
14
OutOfBoundsDatetime ,
15
+ Period ,
15
16
Timedelta ,
16
17
Timestamp ,
17
18
iNaT ,
40
41
is_datetime64_dtype ,
41
42
is_datetime64_ns_dtype ,
42
43
is_datetime64tz_dtype ,
43
- is_datetime_or_timedelta_any_dtype ,
44
44
is_datetime_or_timedelta_dtype ,
45
45
is_dtype_equal ,
46
46
is_extension_array_dtype ,
50
50
is_integer_dtype ,
51
51
is_numeric_dtype ,
52
52
is_object_dtype ,
53
- is_period_dtype ,
54
53
is_scalar ,
55
54
is_sparse ,
56
55
is_string_dtype ,
@@ -132,7 +131,7 @@ def maybe_downcast_to_dtype(result, dtype):
132
131
elif isinstance (result , ABCDataFrame ):
133
132
# occurs in pivot_table doctest
134
133
return result
135
- elif is_period_dtype ( dtype ) :
134
+ elif dtype . type is Period :
136
135
from pandas .core .arrays import PeriodArray
137
136
138
137
with suppress (TypeError ):
@@ -169,7 +168,7 @@ def maybe_downcast_to_dtype(result, dtype):
169
168
170
169
# a datetimelike
171
170
# 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" ]:
173
172
174
173
if is_datetime_or_timedelta_dtype (dtype ):
175
174
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