@@ -9540,10 +9540,6 @@ def align(
9540
9540
level : Level | None = None ,
9541
9541
copy : bool | None = None ,
9542
9542
fill_value : Hashable | None = None ,
9543
- method : FillnaOptions | None | lib .NoDefault = lib .no_default ,
9544
- limit : int | None | lib .NoDefault = lib .no_default ,
9545
- fill_axis : Axis | lib .NoDefault = lib .no_default ,
9546
- broadcast_axis : Axis | None | lib .NoDefault = lib .no_default ,
9547
9543
) -> tuple [Self , NDFrameT ]:
9548
9544
"""
9549
9545
Align two objects on their axes with the specified join method.
@@ -9585,34 +9581,6 @@ def align(
9585
9581
fill_value : scalar, default np.nan
9586
9582
Value to use for missing values. Defaults to NaN, but can be any
9587
9583
"compatible" value.
9588
- method : {{'backfill', 'bfill', 'pad', 'ffill', None}}, default None
9589
- Method to use for filling holes in reindexed Series:
9590
-
9591
- - pad / ffill: propagate last valid observation forward to next valid.
9592
- - backfill / bfill: use NEXT valid observation to fill gap.
9593
-
9594
- .. deprecated:: 2.1
9595
-
9596
- limit : int, default None
9597
- If method is specified, this is the maximum number of consecutive
9598
- NaN values to forward/backward fill. In other words, if there is
9599
- a gap with more than this number of consecutive NaNs, it will only
9600
- be partially filled. If method is not specified, this is the
9601
- maximum number of entries along the entire axis where NaNs will be
9602
- filled. Must be greater than 0 if not None.
9603
-
9604
- .. deprecated:: 2.1
9605
-
9606
- fill_axis : {axes_single_arg}, default 0
9607
- Filling axis, method and limit.
9608
-
9609
- .. deprecated:: 2.1
9610
-
9611
- broadcast_axis : {axes_single_arg}, default None
9612
- Broadcast values along this axis, if aligning two objects of
9613
- different dimensions.
9614
-
9615
- .. deprecated:: 2.1
9616
9584
9617
9585
Returns
9618
9586
-------
@@ -9684,92 +9652,6 @@ def align(
9684
9652
3 60.0 70.0 80.0 90.0 NaN
9685
9653
4 600.0 700.0 800.0 900.0 NaN
9686
9654
"""
9687
- if (
9688
- method is not lib .no_default
9689
- or limit is not lib .no_default
9690
- or fill_axis is not lib .no_default
9691
- ):
9692
- # GH#51856
9693
- warnings .warn (
9694
- "The 'method', 'limit', and 'fill_axis' keywords in "
9695
- f"{ type (self ).__name__ } .align are deprecated and will be removed "
9696
- "in a future version. Call fillna directly on the returned objects "
9697
- "instead." ,
9698
- FutureWarning ,
9699
- stacklevel = find_stack_level (),
9700
- )
9701
- if fill_axis is lib .no_default :
9702
- fill_axis = 0
9703
- if method is lib .no_default :
9704
- method = None
9705
- if limit is lib .no_default :
9706
- limit = None
9707
-
9708
- if method is not None :
9709
- method = clean_fill_method (method )
9710
-
9711
- if broadcast_axis is not lib .no_default :
9712
- # GH#51856
9713
- # TODO(3.0): enforcing this deprecation will close GH#13194
9714
- msg = (
9715
- f"The 'broadcast_axis' keyword in { type (self ).__name__ } .align is "
9716
- "deprecated and will be removed in a future version."
9717
- )
9718
- if broadcast_axis is not None :
9719
- if self .ndim == 1 and other .ndim == 2 :
9720
- msg += (
9721
- " Use left = DataFrame({col: left for col in right.columns}, "
9722
- "index=right.index) before calling `left.align(right)` instead."
9723
- )
9724
- elif self .ndim == 2 and other .ndim == 1 :
9725
- msg += (
9726
- " Use right = DataFrame({col: right for col in left.columns}, "
9727
- "index=left.index) before calling `left.align(right)` instead"
9728
- )
9729
- warnings .warn (msg , FutureWarning , stacklevel = find_stack_level ())
9730
- else :
9731
- broadcast_axis = None
9732
-
9733
- if broadcast_axis == 1 and self .ndim != other .ndim :
9734
- if isinstance (self , ABCSeries ):
9735
- # this means other is a DataFrame, and we need to broadcast
9736
- # self
9737
- cons = self ._constructor_expanddim
9738
- df = cons (
9739
- {c : self for c in other .columns }, ** other ._construct_axes_dict ()
9740
- )
9741
- # error: Incompatible return value type (got "Tuple[DataFrame,
9742
- # DataFrame]", expected "Tuple[Self, NDFrameT]")
9743
- return df ._align_frame ( # type: ignore[return-value]
9744
- other , # type: ignore[arg-type]
9745
- join = join ,
9746
- axis = axis ,
9747
- level = level ,
9748
- fill_value = fill_value ,
9749
- method = method ,
9750
- limit = limit ,
9751
- fill_axis = fill_axis ,
9752
- )[:2 ]
9753
- elif isinstance (other , ABCSeries ):
9754
- # this means self is a DataFrame, and we need to broadcast
9755
- # other
9756
- cons = other ._constructor_expanddim
9757
- df = cons (
9758
- {c : other for c in self .columns }, ** self ._construct_axes_dict ()
9759
- )
9760
- # error: Incompatible return value type (got "Tuple[NDFrameT,
9761
- # DataFrame]", expected "Tuple[Self, NDFrameT]")
9762
- return self ._align_frame ( # type: ignore[return-value]
9763
- df ,
9764
- join = join ,
9765
- axis = axis ,
9766
- level = level ,
9767
- fill_value = fill_value ,
9768
- method = method ,
9769
- limit = limit ,
9770
- fill_axis = fill_axis ,
9771
- )[:2 ]
9772
-
9773
9655
_right : DataFrame | Series
9774
9656
if axis is not None :
9775
9657
axis = self ._get_axis_number (axis )
@@ -9780,9 +9662,6 @@ def align(
9780
9662
axis = axis ,
9781
9663
level = level ,
9782
9664
fill_value = fill_value ,
9783
- method = method ,
9784
- limit = limit ,
9785
- fill_axis = fill_axis ,
9786
9665
)
9787
9666
9788
9667
elif isinstance (other , ABCSeries ):
@@ -9792,9 +9671,6 @@ def align(
9792
9671
axis = axis ,
9793
9672
level = level ,
9794
9673
fill_value = fill_value ,
9795
- method = method ,
9796
- limit = limit ,
9797
- fill_axis = fill_axis ,
9798
9674
)
9799
9675
else : # pragma: no cover
9800
9676
raise TypeError (f"unsupported type: { type (other )} " )
@@ -9825,9 +9701,6 @@ def _align_frame(
9825
9701
axis : Axis | None = None ,
9826
9702
level = None ,
9827
9703
fill_value = None ,
9828
- method = None ,
9829
- limit : int | None = None ,
9830
- fill_axis : Axis = 0 ,
9831
9704
) -> tuple [Self , DataFrame , Index | None ]:
9832
9705
# defaults
9833
9706
join_index , join_columns = None , None
@@ -9864,11 +9737,6 @@ def _align_frame(
9864
9737
fill_value = fill_value ,
9865
9738
allow_dups = True ,
9866
9739
)
9867
-
9868
- if method is not None :
9869
- left = left ._pad_or_backfill (method , axis = fill_axis , limit = limit )
9870
- right = right ._pad_or_backfill (method , axis = fill_axis , limit = limit )
9871
-
9872
9740
return left , right , join_index
9873
9741
9874
9742
@final
@@ -9879,9 +9747,6 @@ def _align_series(
9879
9747
axis : Axis | None = None ,
9880
9748
level = None ,
9881
9749
fill_value = None ,
9882
- method = None ,
9883
- limit : int | None = None ,
9884
- fill_axis : Axis = 0 ,
9885
9750
) -> tuple [Self , Series , Index | None ]:
9886
9751
is_series = isinstance (self , ABCSeries )
9887
9752
@@ -9933,15 +9798,11 @@ def _align_series(
9933
9798
right = other .reindex (join_index , level = level )
9934
9799
9935
9800
# fill
9936
- fill_na = notna (fill_value ) or ( method is not None )
9801
+ fill_na = notna (fill_value )
9937
9802
if fill_na :
9938
- fill_value , method = validate_fillna_kwargs (fill_value , method )
9939
- if method is not None :
9940
- left = left ._pad_or_backfill (method , limit = limit , axis = fill_axis )
9941
- right = right ._pad_or_backfill (method , limit = limit )
9942
- else :
9943
- left = left .fillna (fill_value , limit = limit , axis = fill_axis )
9944
- right = right .fillna (fill_value , limit = limit )
9803
+ fill_value , _ = validate_fillna_kwargs (fill_value , None )
9804
+ left = left .fillna (fill_value )
9805
+ right = right .fillna (fill_value )
9945
9806
9946
9807
return left , right , join_index
9947
9808
0 commit comments