Repository: pandas-dev/pandas

Issue:
DEPR: Deprecate method argument of reindex_like 
### Feature Type

- [X] Adding new functionality to pandas

- [X] Changing existing functionality in pandas

- [X] Removing existing functionality in pandas


### Problem Description

There is a bug report of this in https://github.com/pandas-dev/pandas/issues/34547 The current behavior of the method seems to work closer to DataFrame.update (whether intentional or not). Rather than try and fix I think it would be better to remove the parameter and have users call .fillna() or .update() to get the intended result

### Feature Description

Deprecate

### Alternative Solutions

N/A

### Additional Context

_No response_


Discussion:
take
take
Hi, I'm wondering what the procedure is to deprecate a keyword argument of a method when there is no new name for it, just removing it. Should I change the code to remove the argument and add a deprecation warning, or should I simply add the deprecation warning?

Patch:
diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst
index 083e004fb94fa..62a015402c9e6 100644
--- a/doc/source/whatsnew/v3.0.0.rst
+++ b/doc/source/whatsnew/v3.0.0.rst
@@ -206,6 +206,7 @@ Other Deprecations
 - Deprecated allowing non-keyword arguments in :meth:`Series.to_markdown` except ``buf``. (:issue:`57280`)
 - Deprecated allowing non-keyword arguments in :meth:`Series.to_string` except ``buf``. (:issue:`57280`)
 - Deprecated behavior of :meth:`Series.dt.to_pytimedelta`, in a future version this will return a :class:`Series` containing python ``datetime.timedelta`` objects instead of an ``ndarray`` of timedelta; this matches the behavior of other :meth:`Series.dt` properties. (:issue:`57463`)
+- Deprecated parameter ``method`` in :meth:`DataFrame.reindex_like` / :meth:`Series.reindex_like` (:issue:`58667`)
 - Deprecated using ``epoch`` date format in :meth:`DataFrame.to_json` and :meth:`Series.to_json`, use ``iso`` instead. (:issue:`57063`)
 -
 
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
index 3da047eaa2d4e..0e91aa23fcdb4 100644
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -93,7 +93,10 @@
     InvalidIndexError,
 )
 from pandas.errors.cow import _chained_assignment_method_msg
-from pandas.util._decorators import doc
+from pandas.util._decorators import (
+    deprecate_kwarg,
+    doc,
+)
 from pandas.util._exceptions import find_stack_level
 from pandas.util._validators import (
     check_dtype_backend,
@@ -4301,6 +4304,8 @@ def _check_copy_deprecation(copy):
                 stacklevel=find_stack_level(),
             )
 
+    # issue 58667
+    @deprecate_kwarg("method", None)
     @final
     def reindex_like(
         self,
@@ -4328,6 +4333,8 @@ def reindex_like(
             Please note: this is only applicable to DataFrames/Series with a
             monotonically increasing/decreasing index.
 
+            .. deprecated:: 3.0.0
+
             * None (default): don't fill gaps
             * pad / ffill: propagate last valid observation forward to next
               valid
diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py
index b2b0d711c6b54..69021eb2656f6 100644
--- a/pandas/io/formats/style.py
+++ b/pandas/io/formats/style.py
@@ -3800,7 +3800,7 @@ def _validate_apply_axis_arg(
             f"operations is a Series with 'axis in [0,1]'"
         )
     if isinstance(arg, (Series, DataFrame)):  # align indx / cols to data
-        arg = arg.reindex_like(data, method=None).to_numpy(**dtype)
+        arg = arg.reindex_like(data).to_numpy(**dtype)
     else:
         arg = np.asarray(arg, **dtype)
         assert isinstance(arg, np.ndarray)  # mypy requirement


Test patch:
diff --git a/pandas/conftest.py b/pandas/conftest.py
index e1225f031b568..0ab51139528ad 100644
--- a/pandas/conftest.py
+++ b/pandas/conftest.py
@@ -158,6 +158,7 @@ def pytest_collection_modifyitems(items, config) -> None:
         ("SeriesGroupBy.idxmin", "The behavior of Series.idxmin"),
         ("SeriesGroupBy.idxmax", "The behavior of Series.idxmax"),
         ("to_pytimedelta", "The behavior of TimedeltaProperties.to_pytimedelta"),
+        ("NDFrame.reindex_like", "keyword argument 'method' is deprecated"),
         # Docstring divides by zero to show behavior difference
         ("missing.mask_zero_div_zero", "divide by zero encountered"),
         (
diff --git a/pandas/tests/frame/methods/test_reindex_like.py b/pandas/tests/frame/methods/test_reindex_like.py
index ce68ec28eec3d..03968dcbb6314 100644
--- a/pandas/tests/frame/methods/test_reindex_like.py
+++ b/pandas/tests/frame/methods/test_reindex_like.py
@@ -22,9 +22,11 @@ def test_reindex_like(self, float_frame):
     def test_reindex_like_methods(self, method, expected_values):
         df = DataFrame({"x": list(range(5))})
 
-        result = df.reindex_like(df, method=method, tolerance=0)
+        with tm.assert_produces_warning(FutureWarning):
+            result = df.reindex_like(df, method=method, tolerance=0)
         tm.assert_frame_equal(df, result)
-        result = df.reindex_like(df, method=method, tolerance=[0, 0, 0, 0])
+        with tm.assert_produces_warning(FutureWarning):
+            result = df.reindex_like(df, method=method, tolerance=[0, 0, 0, 0])
         tm.assert_frame_equal(df, result)
 
     def test_reindex_like_subclass(self):
diff --git a/pandas/tests/resample/test_datetime_index.py b/pandas/tests/resample/test_datetime_index.py
index 5ee9b65ba9ae7..c38d223c9d6a0 100644
--- a/pandas/tests/resample/test_datetime_index.py
+++ b/pandas/tests/resample/test_datetime_index.py
@@ -1300,7 +1300,8 @@ def test_resample_consistency(unit):
 
     s10 = s.reindex(index=i10, method="bfill")
     s10_2 = s.reindex(index=i10, method="bfill", limit=2)
-    rl = s.reindex_like(s10, method="bfill", limit=2)
+    with tm.assert_produces_warning(FutureWarning):
+        rl = s.reindex_like(s10, method="bfill", limit=2)
     r10_2 = s.resample("10Min").bfill(limit=2)
     r10 = s.resample("10Min").bfill()
 
diff --git a/pandas/tests/series/methods/test_reindex_like.py b/pandas/tests/series/methods/test_reindex_like.py
index 7f24c778feb1b..10b8ac5817636 100644
--- a/pandas/tests/series/methods/test_reindex_like.py
+++ b/pandas/tests/series/methods/test_reindex_like.py
@@ -20,7 +20,8 @@ def test_reindex_like(datetime_series):
     series1 = Series([5, None, None], [day1, day2, day3])
     series2 = Series([None, None], [day1, day3])
 
-    result = series1.reindex_like(series2, method="pad")
+    with tm.assert_produces_warning(FutureWarning):
+        result = series1.reindex_like(series2, method="pad")
     expected = Series([5, np.nan], index=[day1, day3])
     tm.assert_series_equal(result, expected)
 
@@ -32,10 +33,13 @@ def test_reindex_like_nearest():
     other = ser.reindex(target, method="nearest")
     expected = Series(np.around(target).astype("int64"), target)
 
-    result = ser.reindex_like(other, method="nearest")
+    with tm.assert_produces_warning(FutureWarning):
+        result = ser.reindex_like(other, method="nearest")
     tm.assert_series_equal(expected, result)
 
-    result = ser.reindex_like(other, method="nearest", tolerance=1)
+    with tm.assert_produces_warning(FutureWarning):
+        result = ser.reindex_like(other, method="nearest", tolerance=1)
     tm.assert_series_equal(expected, result)
-    result = ser.reindex_like(other, method="nearest", tolerance=[1, 2, 3, 4])
+    with tm.assert_produces_warning(FutureWarning):
+        result = ser.reindex_like(other, method="nearest", tolerance=[1, 2, 3, 4])
     tm.assert_series_equal(expected, result)