Skip to content

Commit 67fc9e0

Browse files
authored
CLN: index related attributes on Series/DataFrame (#31953)
1 parent 32b3d9e commit 67fc9e0

File tree

3 files changed

+16
-30
lines changed

3 files changed

+16
-30
lines changed

pandas/core/frame.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -8570,6 +8570,14 @@ def isin(self, values) -> "DataFrame":
85708570

85718571
# ----------------------------------------------------------------------
85728572
# Add index and columns
8573+
_AXIS_ORDERS = ["index", "columns"]
8574+
_AXIS_NUMBERS = {"index": 0, "columns": 1}
8575+
_AXIS_NAMES = {0: "index", 1: "columns"}
8576+
_AXIS_REVERSED = True
8577+
_AXIS_LEN = len(_AXIS_ORDERS)
8578+
_info_axis_number = 1
8579+
_info_axis_name = "columns"
8580+
85738581
index: "Index" = properties.AxisProperty(
85748582
axis=1, doc="The index (row labels) of the DataFrame."
85758583
)
@@ -8585,13 +8593,6 @@ def isin(self, values) -> "DataFrame":
85858593
sparse = CachedAccessor("sparse", SparseFrameAccessor)
85868594

85878595

8588-
DataFrame._setup_axes(
8589-
["index", "columns"],
8590-
docs={
8591-
"index": "The index (row labels) of the DataFrame.",
8592-
"columns": "The column labels of the DataFrame.",
8593-
},
8594-
)
85958596
DataFrame._add_numeric_operations()
85968597
DataFrame._add_series_or_dataframe_operations()
85978598

pandas/core/generic.py

-22
Original file line numberDiff line numberDiff line change
@@ -315,28 +315,6 @@ def _constructor_expanddim(self):
315315
_info_axis_name: str
316316
_AXIS_LEN: int
317317

318-
@classmethod
319-
def _setup_axes(cls, axes: List[str], docs: Dict[str, str]) -> None:
320-
"""
321-
Provide axes setup for the major PandasObjects.
322-
323-
Parameters
324-
----------
325-
axes : the names of the axes in order (lowest to highest)
326-
docs : docstrings for the axis properties
327-
"""
328-
info_axis = len(axes) - 1
329-
axes_are_reversed = len(axes) > 1
330-
331-
cls._AXIS_ORDERS = axes
332-
cls._AXIS_NUMBERS = {a: i for i, a in enumerate(axes)}
333-
cls._AXIS_LEN = len(axes)
334-
cls._AXIS_NAMES = dict(enumerate(axes))
335-
cls._AXIS_REVERSED = axes_are_reversed
336-
337-
cls._info_axis_number = info_axis
338-
cls._info_axis_name = axes[info_axis]
339-
340318
def _construct_axes_dict(self, axes=None, **kwargs):
341319
"""Return an axes dictionary for myself."""
342320
d = {a: self._get_axis(a) for a in (axes or self._AXIS_ORDERS)}

pandas/core/series.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -4564,6 +4564,14 @@ def to_period(self, freq=None, copy=True) -> "Series":
45644564

45654565
# ----------------------------------------------------------------------
45664566
# Add index
4567+
_AXIS_ORDERS = ["index"]
4568+
_AXIS_NUMBERS = {"index": 0}
4569+
_AXIS_NAMES = {0: "index"}
4570+
_AXIS_REVERSED = False
4571+
_AXIS_LEN = len(_AXIS_ORDERS)
4572+
_info_axis_number = 0
4573+
_info_axis_name = "index"
4574+
45674575
index: "Index" = properties.AxisProperty(
45684576
axis=0, doc="The index (axis labels) of the Series."
45694577
)
@@ -4582,7 +4590,6 @@ def to_period(self, freq=None, copy=True) -> "Series":
45824590
hist = pandas.plotting.hist_series
45834591

45844592

4585-
Series._setup_axes(["index"], docs={"index": "The index (axis labels) of the Series."})
45864593
Series._add_numeric_operations()
45874594
Series._add_series_or_dataframe_operations()
45884595

0 commit comments

Comments
 (0)