diff --git a/pandas/core/frame.py b/pandas/core/frame.py index da152b70abd2e..8cad92ab2bb32 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -8569,6 +8569,14 @@ def isin(self, values) -> "DataFrame": # ---------------------------------------------------------------------- # Add index and columns + _AXIS_ORDERS = ["index", "columns"] + _AXIS_NUMBERS = {"index": 0, "columns": 1} + _AXIS_NAMES = {0: "index", 1: "columns"} + _AXIS_REVERSED = True + _AXIS_LEN = len(_AXIS_ORDERS) + _info_axis_number = 1 + _info_axis_name = "columns" + index: "Index" = properties.AxisProperty( axis=1, doc="The index (row labels) of the DataFrame." ) @@ -8584,13 +8592,6 @@ def isin(self, values) -> "DataFrame": sparse = CachedAccessor("sparse", SparseFrameAccessor) -DataFrame._setup_axes( - ["index", "columns"], - docs={ - "index": "The index (row labels) of the DataFrame.", - "columns": "The column labels of the DataFrame.", - }, -) DataFrame._add_numeric_operations() DataFrame._add_series_or_dataframe_operations() diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 934c4c6e92bbe..60d152eba4485 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -315,28 +315,6 @@ def _constructor_expanddim(self): _info_axis_name: str _AXIS_LEN: int - @classmethod - def _setup_axes(cls, axes: List[str], docs: Dict[str, str]) -> None: - """ - Provide axes setup for the major PandasObjects. - - Parameters - ---------- - axes : the names of the axes in order (lowest to highest) - docs : docstrings for the axis properties - """ - info_axis = len(axes) - 1 - axes_are_reversed = len(axes) > 1 - - cls._AXIS_ORDERS = axes - cls._AXIS_NUMBERS = {a: i for i, a in enumerate(axes)} - cls._AXIS_LEN = len(axes) - cls._AXIS_NAMES = dict(enumerate(axes)) - cls._AXIS_REVERSED = axes_are_reversed - - cls._info_axis_number = info_axis - cls._info_axis_name = axes[info_axis] - def _construct_axes_dict(self, axes=None, **kwargs): """Return an axes dictionary for myself.""" d = {a: self._get_axis(a) for a in (axes or self._AXIS_ORDERS)} diff --git a/pandas/core/series.py b/pandas/core/series.py index 24e794014a15f..f6536884e007a 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4562,6 +4562,14 @@ def to_period(self, freq=None, copy=True) -> "Series": # ---------------------------------------------------------------------- # Add index + _AXIS_ORDERS = ["index"] + _AXIS_NUMBERS = {"index": 0} + _AXIS_NAMES = {0: "index"} + _AXIS_REVERSED = False + _AXIS_LEN = len(_AXIS_ORDERS) + _info_axis_number = 0 + _info_axis_name = "index" + index: "Index" = properties.AxisProperty( axis=0, doc="The index (axis labels) of the Series." ) @@ -4580,7 +4588,6 @@ def to_period(self, freq=None, copy=True) -> "Series": hist = pandas.plotting.hist_series -Series._setup_axes(["index"], docs={"index": "The index (axis labels) of the Series."}) Series._add_numeric_operations() Series._add_series_or_dataframe_operations()