@@ -3939,21 +3939,69 @@ def _validate_can_reindex(self, indexer: np.ndarray) -> None:
3939
3939
raise ValueError ("cannot reindex on an axis with duplicate labels" )
3940
3940
3941
3941
def reindex (
3942
- self , target , method = None , level = None , limit = None , tolerance = None
3942
+ self ,
3943
+ target ,
3944
+ method : str | None = None ,
3945
+ level : int | None = None ,
3946
+ limit : int | None = None ,
3947
+ tolerance : int | float | None = None ,
3943
3948
) -> tuple [Index , npt .NDArray [np .intp ] | None ]:
3944
3949
"""
3945
3950
Create index with target's values.
3946
3951
3947
3952
Parameters
3948
3953
----------
3949
3954
target : an iterable
3955
+ method : {None, 'pad'/'ffill', 'backfill'/'bfill', 'nearest'}, optional
3956
+ * default: exact matches only.
3957
+ * pad / ffill: find the PREVIOUS index value if no exact match.
3958
+ * backfill / bfill: use NEXT index value if no exact match
3959
+ * nearest: use the NEAREST index value if no exact match. Tied
3960
+ distances are broken by preferring the larger index value.
3961
+ level : int, optional
3962
+ Level of multiindex.
3963
+ limit : int, optional
3964
+ Maximum number of consecutive labels in ``target`` to match for
3965
+ inexact matches.
3966
+ tolerance : int or float, optional
3967
+ Maximum distance between original and new labels for inexact
3968
+ matches. The values of the index at the matching locations must
3969
+ satisfy the equation ``abs(index[indexer] - target) <= tolerance``.
3970
+
3971
+ Tolerance may be a scalar value, which applies the same tolerance
3972
+ to all values, or list-like, which applies variable tolerance per
3973
+ element. List-like includes list, tuple, array, Series, and must be
3974
+ the same size as the index and its dtype must exactly match the
3975
+ index's type.
3950
3976
3951
3977
Returns
3952
3978
-------
3953
3979
new_index : pd.Index
3954
3980
Resulting index.
3955
3981
indexer : np.ndarray[np.intp] or None
3956
3982
Indices of output values in original index.
3983
+
3984
+ Raises
3985
+ ------
3986
+ TypeError
3987
+ If ``method`` passed along with ``level``.
3988
+ ValueError
3989
+ If non-unique multi-index
3990
+ ValueError
3991
+ If non-unique index and ``method`` or ``limit`` passed.
3992
+
3993
+ See Also
3994
+ --------
3995
+ Series.reindex
3996
+ DataFrame.reindex
3997
+
3998
+ Examples
3999
+ --------
4000
+ >>> idx = pd.Index(['car', 'bike', 'train', 'tractor'])
4001
+ >>> idx
4002
+ Index(['car', 'bike', 'train', 'tractor'], dtype='object')
4003
+ >>> idx.reindex(['car', 'bike'])
4004
+ (Index(['car', 'bike'], dtype='object'), array([0, 1], dtype=int64))
3957
4005
"""
3958
4006
# GH6552: preserve names when reindexing to non-named target
3959
4007
# (i.e. neither Index nor Series).
0 commit comments