diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py index e3eeca2c45e76..66723969c9f10 100644 --- a/pandas/core/indexes/datetimelike.py +++ b/pandas/core/indexes/datetimelike.py @@ -80,7 +80,16 @@ def wrapper(left, right): cache=True, ) @inherit_names( - ["__iter__", "mean", "freq", "freqstr", "_ndarray_values", "asi8", "_box_values"], + [ + "__iter__", + "mean", + "freq", + "freqstr", + "_ndarray_values", + "asi8", + "_box_values", + "_box_func", + ], DatetimeLikeArrayMixin, ) class DatetimeIndexOpsMixin(ExtensionIndex): diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index 2b4636155111f..e3245d6e419ed 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -70,7 +70,6 @@ def _new_DatetimeIndex(cls, d): "_field_ops", "_datetimelike_ops", "_datetimelike_methods", - "_box_func", "tz", "tzinfo", "dtype", diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 75c100c9d2c08..ad88608dba1c9 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -280,22 +280,6 @@ def _shallow_copy_with_infer(self, values=None, **kwargs): """ we always want to return a PeriodIndex """ return self._shallow_copy(values=values, **kwargs) - @property - def _box_func(self): - """Maybe box an ordinal or Period""" - # TODO(DatetimeArray): Avoid double-boxing - # PeriodArray takes care of boxing already, so we need to check - # whether we're given an ordinal or a Period. It seems like some - # places outside of indexes/period.py are calling this _box_func, - # but passing data that's already boxed. - def func(x): - if isinstance(x, Period) or x is NaT: - return x - else: - return Period._from_ordinal(ordinal=x, freq=self.freq) - - return func - def _maybe_convert_timedelta(self, other): """ Convert timedelta-like input to an integer multiple of self.freq diff --git a/pandas/core/indexes/timedeltas.py b/pandas/core/indexes/timedeltas.py index 08a07e8d30348..f5cf87ea700a6 100644 --- a/pandas/core/indexes/timedeltas.py +++ b/pandas/core/indexes/timedeltas.py @@ -53,7 +53,6 @@ "_datetimelike_methods", "_other_ops", "components", - "_box_func", "to_pytimedelta", "sum", "std",