Skip to content

Commit bc823be

Browse files
committed
feedback: revert changes to dtype checks
1 parent 757233e commit bc823be

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

pandas/core/dtypes/cast.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from pandas._libs.tslibs import (
2424
NaT,
2525
OutOfBoundsDatetime,
26+
Period,
2627
Timedelta,
2728
Timestamp,
2829
conversion,
@@ -53,7 +54,6 @@
5354
is_datetime64_dtype,
5455
is_datetime64_ns_dtype,
5556
is_datetime64tz_dtype,
56-
is_datetime_or_timedelta_any_dtype,
5757
is_datetime_or_timedelta_dtype,
5858
is_dtype_equal,
5959
is_extension_array_dtype,
@@ -63,7 +63,6 @@
6363
is_integer_dtype,
6464
is_numeric_dtype,
6565
is_object_dtype,
66-
is_period_dtype,
6766
is_scalar,
6867
is_sparse,
6968
is_string_dtype,
@@ -147,7 +146,7 @@ def maybe_downcast_to_dtype(result, dtype: Dtype):
147146
elif isinstance(result, ABCDataFrame):
148147
# occurs in pivot_table doctest
149148
return result
150-
elif is_period_dtype(dtype):
149+
elif dtype.type is Period:
151150
from pandas.core.arrays import PeriodArray
152151

153152
with suppress(TypeError):
@@ -184,7 +183,7 @@ def maybe_downcast_to_dtype(result, dtype: Dtype):
184183

185184
# a datetimelike
186185
# 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"]:
188187

189188
if is_datetime_or_timedelta_dtype(dtype):
190189
result = result.astype(dtype)

pandas/core/dtypes/common.py

-4
Original file line numberDiff line numberDiff 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
10751071
def is_numeric_v_string_like(a, b):
10761072
"""

0 commit comments

Comments
 (0)