From a6571fc95275fd97c9aa3901c814629e2d056a94 Mon Sep 17 00:00:00 2001 From: Brock Date: Sun, 23 May 2021 21:43:46 -0700 Subject: [PATCH] CLN: remove unnecessary _comparables --- pandas/core/indexes/datetimelike.py | 3 +++ pandas/core/indexes/datetimes.py | 5 ----- pandas/core/indexes/interval.py | 4 +--- pandas/core/indexes/period.py | 3 --- pandas/core/indexes/timedeltas.py | 4 ---- 5 files changed, 4 insertions(+), 15 deletions(-) diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py index b2377f5b27966..ed7c119c4c2e6 100644 --- a/pandas/core/indexes/datetimelike.py +++ b/pandas/core/indexes/datetimelike.py @@ -83,6 +83,7 @@ class DatetimeIndexOpsMixin(NDArrayBackedExtensionIndex): Common ops mixin to support a unified interface datetimelike Index. """ + _is_numeric_dtype = False _can_hold_strings = False _data: DatetimeArray | TimedeltaArray | PeriodArray freq: BaseOffset | None @@ -612,6 +613,8 @@ class DatetimeTimedeltaMixin(DatetimeIndexOpsMixin): """ _data: DatetimeArray | TimedeltaArray + _comparables = ["name", "freq"] + _attributes = ["name", "freq"] # Compat for frequency inference, see GH#23789 _is_monotonic_increasing = Index.is_monotonic_increasing diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index ac09159c23566..5d6a4c08d0321 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -257,11 +257,6 @@ class DatetimeIndex(DatetimeTimedeltaMixin): _engine_type = libindex.DatetimeEngine _supports_partial_string_indexing = True - _comparables = ["name", "freqstr", "tz"] - _attributes = ["name", "tz", "freq"] - - _is_numeric_dtype = False - _data: DatetimeArray inferred_freq: str | None tz: tzinfo | None diff --git a/pandas/core/indexes/interval.py b/pandas/core/indexes/interval.py index fc92a1b3afe53..439ebd34a8ecc 100644 --- a/pandas/core/indexes/interval.py +++ b/pandas/core/indexes/interval.py @@ -255,8 +255,6 @@ def func(self, other, sort=None): @inherit_names(["is_non_overlapping_monotonic", "closed"], IntervalArray, cache=True) class IntervalIndex(ExtensionIndex): _typ = "intervalindex" - _comparables = ["name"] - _attributes = ["name", "closed"] # annotate properties pinned via inherit_names closed: str @@ -427,7 +425,7 @@ def __array_wrap__(self, result, context=None): return result def __reduce__(self): - d = {"left": self.left, "right": self.right} + d = {"left": self.left, "right": self.right, "closed": self.closed} d.update(self._get_attributes_dict()) return _new_IntervalIndex, (type(self), d), None diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 136843938b683..149cc7b051e22 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -159,9 +159,6 @@ class PeriodIndex(DatetimeIndexOpsMixin): _typ = "periodindex" _attributes = ["name", "freq"] - # define my properties & methods for delegation - _is_numeric_dtype = False - _data: PeriodArray freq: BaseOffset diff --git a/pandas/core/indexes/timedeltas.py b/pandas/core/indexes/timedeltas.py index ec97fa1e05851..cb83a0bccc748 100644 --- a/pandas/core/indexes/timedeltas.py +++ b/pandas/core/indexes/timedeltas.py @@ -112,10 +112,6 @@ class TimedeltaIndex(DatetimeTimedeltaMixin): _data_cls = TimedeltaArray _engine_type = libindex.TimedeltaEngine - _comparables = ["name", "freq"] - _attributes = ["name", "freq"] - _is_numeric_dtype = False - _data: TimedeltaArray # -------------------------------------------------------------------