diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index ceed7e29e4a35..bc479ee8f9c1f 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -21,10 +21,11 @@ from pandas._libs.interval import Interval from pandas._libs.tslibs import NaT, Period, Timestamp, timezones +from pandas._libs.tslibs.offsets import BaseOffset from pandas._typing import DtypeObj, Ordered from pandas.core.dtypes.base import ExtensionDtype -from pandas.core.dtypes.generic import ABCCategoricalIndex, ABCDateOffset, ABCIndexClass +from pandas.core.dtypes.generic import ABCCategoricalIndex, ABCIndexClass from pandas.core.dtypes.inference import is_bool, is_list_like if TYPE_CHECKING: @@ -893,7 +894,7 @@ def __new__(cls, freq=None): u._freq = None return u - if not isinstance(freq, ABCDateOffset): + if not isinstance(freq, BaseOffset): freq = cls._parse_dtype_strict(freq) try: @@ -935,7 +936,7 @@ def construct_from_string(cls, string: str_type) -> "PeriodDtype": if ( isinstance(string, str) and (string.startswith("period[") or string.startswith("Period[")) - or isinstance(string, ABCDateOffset) + or isinstance(string, BaseOffset) ): # do not parse string like U as period[U] # avoid tuple to be regarded as freq diff --git a/pandas/core/dtypes/generic.py b/pandas/core/dtypes/generic.py index 7f98ca3d402bc..04067f9eb3fb8 100644 --- a/pandas/core/dtypes/generic.py +++ b/pandas/core/dtypes/generic.py @@ -63,7 +63,6 @@ def _check(cls, inst) -> bool: "ABCTimedeltaArray", "_typ", ("timedeltaarray") ) ABCPeriodArray = create_pandas_abc_type("ABCPeriodArray", "_typ", ("periodarray",)) -ABCDateOffset = create_pandas_abc_type("ABCDateOffset", "_typ", ("dateoffset",)) ABCExtensionArray = create_pandas_abc_type( "ABCExtensionArray", "_typ", diff --git a/pandas/core/window/rolling.py b/pandas/core/window/rolling.py index 6c775953e18db..3ac3d4010be87 100644 --- a/pandas/core/window/rolling.py +++ b/pandas/core/window/rolling.py @@ -28,7 +28,6 @@ ) from pandas.core.dtypes.generic import ( ABCDataFrame, - ABCDateOffset, ABCDatetimeIndex, ABCPeriodIndex, ABCSeries, @@ -57,6 +56,8 @@ ) from pandas.core.window.numba_ import generate_numba_apply_func +from pandas.tseries.offsets import DateOffset + class _Window(PandasObject, ShallowMixin, SelectionMixin): _attributes: List[str] = [ @@ -1838,7 +1839,7 @@ def validate(self): # we allow rolling on a datetimelike index if (self.obj.empty or self.is_datetimelike) and isinstance( - self.window, (str, ABCDateOffset, timedelta) + self.window, (str, DateOffset, timedelta) ): self._validate_monotonic() diff --git a/pandas/tests/dtypes/test_generic.py b/pandas/tests/dtypes/test_generic.py index f9ee943d9e6bf..8a897d026f7c5 100644 --- a/pandas/tests/dtypes/test_generic.py +++ b/pandas/tests/dtypes/test_generic.py @@ -38,10 +38,6 @@ def test_abc_types(self): assert isinstance(self.sparse_array, gt.ABCSparseArray) assert isinstance(self.categorical, gt.ABCCategorical) - assert isinstance(pd.DateOffset(), gt.ABCDateOffset) - assert isinstance(pd.Period("2012", freq="A-DEC").freq, gt.ABCDateOffset) - assert not isinstance(pd.Period("2012", freq="A-DEC"), gt.ABCDateOffset) - assert isinstance(self.datetime_array, gt.ABCDatetimeArray) assert not isinstance(self.datetime_index, gt.ABCDatetimeArray)