Skip to content

Commit 788695c

Browse files
authored
CLN: remove axis keyword from Block.pad_or_backill (#58038)
1 parent 8405a07 commit 788695c

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

pandas/core/generic.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -6727,12 +6727,10 @@ def _pad_or_backfill(
67276727
axis = self._get_axis_number(axis)
67286728
method = clean_fill_method(method)
67296729

6730-
if not self._mgr.is_single_block and axis == 1:
6731-
# e.g. test_align_fill_method
6732-
# TODO(3.0): once downcast is removed, we can do the .T
6733-
# in all axis=1 cases, and remove axis kward from mgr.pad_or_backfill.
6734-
if inplace:
6730+
if axis == 1:
6731+
if not self._mgr.is_single_block and inplace:
67356732
raise NotImplementedError()
6733+
# e.g. test_align_fill_method
67366734
result = self.T._pad_or_backfill(
67376735
method=method, limit=limit, limit_area=limit_area
67386736
).T
@@ -6741,7 +6739,6 @@ def _pad_or_backfill(
67416739

67426740
new_mgr = self._mgr.pad_or_backfill(
67436741
method=method,
6744-
axis=self._get_block_manager_axis(axis),
67456742
limit=limit,
67466743
limit_area=limit_area,
67476744
inplace=inplace,

pandas/core/internals/blocks.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,6 @@ def pad_or_backfill(
13431343
self,
13441344
*,
13451345
method: FillnaOptions,
1346-
axis: AxisInt = 0,
13471346
inplace: bool = False,
13481347
limit: int | None = None,
13491348
limit_area: Literal["inside", "outside"] | None = None,
@@ -1357,16 +1356,12 @@ def pad_or_backfill(
13571356
# Dispatch to the NumpyExtensionArray method.
13581357
# We know self.array_values is a NumpyExtensionArray bc EABlock overrides
13591358
vals = cast(NumpyExtensionArray, self.array_values)
1360-
if axis == 1:
1361-
vals = vals.T
1362-
new_values = vals._pad_or_backfill(
1359+
new_values = vals.T._pad_or_backfill(
13631360
method=method,
13641361
limit=limit,
13651362
limit_area=limit_area,
13661363
copy=copy,
1367-
)
1368-
if axis == 1:
1369-
new_values = new_values.T
1364+
).T
13701365

13711366
data = extract_array(new_values, extract_numpy=True)
13721367
return [self.make_block_same_class(data, refs=refs)]
@@ -1814,7 +1809,6 @@ def pad_or_backfill(
18141809
self,
18151810
*,
18161811
method: FillnaOptions,
1817-
axis: AxisInt = 0,
18181812
inplace: bool = False,
18191813
limit: int | None = None,
18201814
limit_area: Literal["inside", "outside"] | None = None,
@@ -1827,11 +1821,11 @@ def pad_or_backfill(
18271821
elif limit_area is not None:
18281822
raise NotImplementedError(
18291823
f"{type(values).__name__} does not implement limit_area "
1830-
"(added in pandas 2.2). 3rd-party ExtnsionArray authors "
1824+
"(added in pandas 2.2). 3rd-party ExtensionArray authors "
18311825
"need to add this argument to _pad_or_backfill."
18321826
)
18331827

1834-
if values.ndim == 2 and axis == 1:
1828+
if values.ndim == 2:
18351829
# NDArrayBackedExtensionArray.fillna assumes axis=0
18361830
new_values = values.T._pad_or_backfill(**kwargs).T
18371831
else:

0 commit comments

Comments
 (0)