Repository: pandas-dev/pandas

Issue:
BUG: DataFrame.reindex not following limit - 方法参数的错误
Python版本: 3.6.5
版本:pandas == 0.24.2
```python
import pandas as pd

Data = [
    ["A", "A", "A"],
    ["B", "B", "B"],
    ["C", "C", "C"],
    ["D", "D", "D"],
]
test1 = pd.DataFrame(Data)
print(test1)
print("------------")
test1 = test1.reindex([0, 1, 2, 3, 4, 5], method="ffill", limit=1)
print(test1)
```
![reindex_bug](https://user-images.githubusercontent.com/10058240/65697799-f4782c80-e051-11e9-9c5d-0bf303535d54.png)


limit参数限制数据继续向后填充

版本:pandas==0.25.1
```python
import pandas as pd

Data = [
    ["A", "A", "A"],
    ["B", "B", "B"],
    ["C", "C", "C"],
    ["D", "D", "D"],
]
test1 = pd.DataFrame(Data)
print(test1)
print("------------")
test1 = test1.reindex([0, 1, 2, 3, 4, 5], method="ffill", limit=1)
print(test1)
```
![reindex_bug_2](https://user-images.githubusercontent.com/10058240/65697820-fc37d100-e051-11e9-9fd3-6fedb7c12c61.png)



limit参数并没有限制数据继续向后填充


Discussion:

Resolving patch:
diff --git a/pandas/core/indexes/range.py b/pandas/core/indexes/range.py
--- a/pandas/core/indexes/range.py
+++ b/pandas/core/indexes/range.py
@@ -380,8 +380,10 @@ def get_loc(self, key, method=None, tolerance=None):
 
     @Appender(_index_shared_docs["get_indexer"])
     def get_indexer(self, target, method=None, limit=None, tolerance=None):
-        if not (method is None and tolerance is None and is_list_like(target)):
-            return super().get_indexer(target, method=method, tolerance=tolerance)
+        if com.any_not_none(method, tolerance, limit) or not is_list_like(target):
+            return super().get_indexer(
+                target, method=method, tolerance=tolerance, limit=limit
+            )
 
         if self.step > 0:
             start, stop, step = self.start, self.stop, self.step


Test patch:
diff --git a/pandas/tests/frame/test_indexing.py b/pandas/tests/frame/test_indexing.py
--- a/pandas/tests/frame/test_indexing.py
+++ b/pandas/tests/frame/test_indexing.py
@@ -2217,6 +2217,22 @@ def test_reindex_frame_add_nat(self):
         assert mask[-5:].all()
         assert not mask[:-5].any()
 
+    def test_reindex_limit(self):
+        # GH 28631
+        data = [["A", "A", "A"], ["B", "B", "B"], ["C", "C", "C"], ["D", "D", "D"]]
+        exp_data = [
+            ["A", "A", "A"],
+            ["B", "B", "B"],
+            ["C", "C", "C"],
+            ["D", "D", "D"],
+            ["D", "D", "D"],
+            [np.nan, np.nan, np.nan],
+        ]
+        df = DataFrame(data)
+        result = df.reindex([0, 1, 2, 3, 4, 5], method="ffill", limit=1)
+        expected = DataFrame(exp_data)
+        tm.assert_frame_equal(result, expected)
+
     def test_set_dataframe_column_ns_dtype(self):
         x = DataFrame([datetime.now(), datetime.now()])
         assert x[0].dtype == np.dtype("M8[ns]")
diff --git a/pandas/tests/indexes/test_range.py b/pandas/tests/indexes/test_range.py
--- a/pandas/tests/indexes/test_range.py
+++ b/pandas/tests/indexes/test_range.py
@@ -416,6 +416,14 @@ def test_get_indexer_backfill(self):
         expected = np.array([0, 1, 1, 2, 2, 3, 3, 4, 4, 5], dtype=np.intp)
         tm.assert_numpy_array_equal(indexer, expected)
 
+    def test_get_indexer_limit(self):
+        # GH 28631
+        idx = RangeIndex(4)
+        target = RangeIndex(6)
+        result = idx.get_indexer(target, method="pad", limit=1)
+        expected = np.array([0, 1, 2, 3, 3, -1], dtype=np.intp)
+        tm.assert_numpy_array_equal(result, expected)
+
     def test_join_outer(self):
         # join with Int64Index
         other = Int64Index(np.arange(25, 14, -1))