Skip to content

Commit fd99c30

Browse files
authored
CLN: remove _AXIS_REVERSED (#44330)
1 parent 057c6f8 commit fd99c30

File tree

6 files changed

+10
-22
lines changed

6 files changed

+10
-22
lines changed

pandas/core/frame.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1686,9 +1686,7 @@ def to_numpy(
16861686
self._consolidate_inplace()
16871687
if dtype is not None:
16881688
dtype = np.dtype(dtype)
1689-
result = self._mgr.as_array(
1690-
transpose=self._AXIS_REVERSED, dtype=dtype, copy=copy, na_value=na_value
1691-
)
1689+
result = self._mgr.as_array(dtype=dtype, copy=copy, na_value=na_value)
16921690
if result.dtype is not dtype:
16931691
result = np.array(result, dtype=dtype, copy=False)
16941692

@@ -10715,7 +10713,6 @@ def isin(self, values) -> DataFrame:
1071510713
1: 1,
1071610714
"columns": 1,
1071710715
}
10718-
_AXIS_REVERSED = True
1071910716
_AXIS_LEN = len(_AXIS_ORDERS)
1072010717
_info_axis_number = 1
1072110718
_info_axis_name = "columns"
@@ -10840,7 +10837,7 @@ def values(self) -> np.ndarray:
1084010837
['monkey', nan, None]], dtype=object)
1084110838
"""
1084210839
self._consolidate_inplace()
10843-
return self._mgr.as_array(transpose=True)
10840+
return self._mgr.as_array()
1084410841

1084510842
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self"])
1084610843
def ffill(

pandas/core/generic.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,6 @@ def _data(self):
479479
_stat_axis_name = "index"
480480
_AXIS_ORDERS: list[str]
481481
_AXIS_TO_AXIS_NUMBER: dict[Axis, int] = {0: 0, "index": 0, "rows": 0}
482-
_AXIS_REVERSED: bool_t
483482
_info_axis_number: int
484483
_info_axis_name: str
485484
_AXIS_LEN: int
@@ -566,9 +565,10 @@ def _get_axis(self, axis: Axis) -> Index:
566565
def _get_block_manager_axis(cls, axis: Axis) -> int:
567566
"""Map the axis to the block_manager axis."""
568567
axis = cls._get_axis_number(axis)
569-
if cls._AXIS_REVERSED:
570-
m = cls._AXIS_LEN - 1
571-
return m - axis
568+
ndim = cls._AXIS_LEN
569+
if ndim == 2:
570+
# i.e. DataFrame
571+
return 1 - axis
572572
return axis
573573

574574
@final

pandas/core/internals/array_manager.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,6 @@ def unstack(self, unstacker, fill_value) -> ArrayManager:
10821082

10831083
def as_array(
10841084
self,
1085-
transpose: bool = False,
10861085
dtype=None,
10871086
copy: bool = False,
10881087
na_value=lib.no_default,
@@ -1092,8 +1091,6 @@ def as_array(
10921091
10931092
Parameters
10941093
----------
1095-
transpose : bool, default False
1096-
If True, transpose the return array.
10971094
dtype : object, default None
10981095
Data type of the return array.
10991096
copy : bool, default False
@@ -1109,7 +1106,7 @@ def as_array(
11091106
"""
11101107
if len(self.arrays) == 0:
11111108
empty_arr = np.empty(self.shape, dtype=float)
1112-
return empty_arr.transpose() if transpose else empty_arr
1109+
return empty_arr.transpose()
11131110

11141111
# We want to copy when na_value is provided to avoid
11151112
# mutating the original object
@@ -1137,8 +1134,6 @@ def as_array(
11371134
result[isna(result)] = na_value
11381135

11391136
return result
1140-
# FIXME: don't leave commented-out
1141-
# return arr.transpose() if transpose else arr
11421137

11431138

11441139
class SingleArrayManager(BaseArrayManager, SingleDataManager):

pandas/core/internals/managers.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,6 @@ def to_dict(self, copy: bool = True):
14651465

14661466
def as_array(
14671467
self,
1468-
transpose: bool = False,
14691468
dtype: np.dtype | None = None,
14701469
copy: bool = False,
14711470
na_value=lib.no_default,
@@ -1475,8 +1474,6 @@ def as_array(
14751474
14761475
Parameters
14771476
----------
1478-
transpose : bool, default False
1479-
If True, transpose the return array.
14801477
dtype : np.dtype or None, default None
14811478
Data type of the return array.
14821479
copy : bool, default False
@@ -1492,7 +1489,7 @@ def as_array(
14921489
"""
14931490
if len(self.blocks) == 0:
14941491
arr = np.empty(self.shape, dtype=float)
1495-
return arr.transpose() if transpose else arr
1492+
return arr.transpose()
14961493

14971494
# We want to copy when na_value is provided to avoid
14981495
# mutating the original object
@@ -1524,7 +1521,7 @@ def as_array(
15241521
if na_value is not lib.no_default:
15251522
arr[isna(arr)] = na_value
15261523

1527-
return arr.transpose() if transpose else arr
1524+
return arr.transpose()
15281525

15291526
def _interleave(
15301527
self,

pandas/core/series.py

-1
Original file line numberDiff line numberDiff line change
@@ -5498,7 +5498,6 @@ def mask(
54985498
# ----------------------------------------------------------------------
54995499
# Add index
55005500
_AXIS_ORDERS = ["index"]
5501-
_AXIS_REVERSED = False
55025501
_AXIS_LEN = len(_AXIS_ORDERS)
55035502
_info_axis_number = 0
55045503
_info_axis_name = "index"

pandas/tests/internals/test_internals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ def test_validate_bool_args(self, value):
851851
def _as_array(mgr):
852852
if mgr.ndim == 1:
853853
return mgr.external_values()
854-
return mgr.as_array()
854+
return mgr.as_array().T
855855

856856

857857
class TestIndexing:

0 commit comments

Comments
 (0)