Skip to content

Commit a61b8cd

Browse files
committed
CLN: index related attributes on Series/DataFrame
1 parent 8a7fbbe commit a61b8cd

File tree

3 files changed

+14
-30
lines changed

3 files changed

+14
-30
lines changed

pandas/core/frame.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8575,6 +8575,13 @@ def isin(self, values) -> "DataFrame":
85758575
columns: "Index" = properties.AxisProperty(
85768576
axis=0, doc="The column labels of the DataFrame."
85778577
)
8578+
_AXIS_ORDERS = ["index", "columns"]
8579+
_AXIS_NUMBERS = {"index": 0, "columns": 1}
8580+
_AXIS_NAMES = {0: "index", 1: "columns"}
8581+
_AXIS_REVERSED = True
8582+
_info_axis_number = 1
8583+
_info_axis_name = _AXIS_ORDERS[_info_axis_number]
8584+
_AXIS_LEN = len(_AXIS_ORDERS)
85788585

85798586
# ----------------------------------------------------------------------
85808587
# Add plotting methods to DataFrame
@@ -8584,13 +8591,6 @@ def isin(self, values) -> "DataFrame":
85848591
sparse = CachedAccessor("sparse", SparseFrameAccessor)
85858592

85868593

8587-
DataFrame._setup_axes(
8588-
["index", "columns"],
8589-
docs={
8590-
"index": "The index (row labels) of the DataFrame.",
8591-
"columns": "The column labels of the DataFrame.",
8592-
},
8593-
)
85948594
DataFrame._add_numeric_operations()
85958595
DataFrame._add_series_or_dataframe_operations()
85968596

pandas/core/generic.py

Lines changed: 0 additions & 22 deletions
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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4565,6 +4565,13 @@ def to_period(self, freq=None, copy=True) -> "Series":
45654565
index: "Index" = properties.AxisProperty(
45664566
axis=0, doc="The index (axis labels) of the Series."
45674567
)
4568+
_AXIS_ORDERS = ["index"]
4569+
_AXIS_NUMBERS = {"index": 0}
4570+
_AXIS_NAMES = {0: "index"}
4571+
_AXIS_REVERSED = False
4572+
_info_axis_number = 0
4573+
_info_axis_name = _AXIS_ORDERS[_info_axis_number]
4574+
_AXIS_LEN = len(_AXIS_ORDERS)
45684575

45694576
# ----------------------------------------------------------------------
45704577
# Accessor Methods
@@ -4580,7 +4587,6 @@ def to_period(self, freq=None, copy=True) -> "Series":
45804587
hist = pandas.plotting.hist_series
45814588

45824589

4583-
Series._setup_axes(["index"], docs={"index": "The index (axis labels) of the Series."})
45844590
Series._add_numeric_operations()
45854591
Series._add_series_or_dataframe_operations()
45864592

0 commit comments

Comments
 (0)