Skip to content

Commit e190435

Browse files
Brian TuBrian Tu
Brian Tu
authored and
Brian Tu
committed
ENH: tolerance now takes list-like argument for reindex and get_indexer.
1 parent 44b08f2 commit e190435

File tree

17 files changed

+264
-167
lines changed

17 files changed

+264
-167
lines changed

doc/source/whatsnew/v0.21.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ Other Enhancements
234234
- :meth:`DataFrame.assign` will preserve the original order of ``**kwargs`` for Python 3.6+ users instead of sorting the column names. (:issue:`14207`)
235235
- Improved the import time of pandas by about 2.25x. (:issue:`16764`)
236236
- :func:`read_json` and :func:`to_json` now accept a ``compression`` argument which allows them to transparently handle compressed files. (:issue:`17798`)
237+
- :func:`Series.reindex`, :func:`DataFrame.reindex`, :func:`Index.get_indexer` now support list-like argument for ``tolerance``. (:issue:`17367`)
237238

238239
.. _whatsnew_0210.api_breaking:
239240

pandas/core/generic.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -2470,9 +2470,10 @@ def reindex_like(self, other, method=None, copy=True, limit=None,
24702470
Maximum number of consecutive labels to fill for inexact matches.
24712471
tolerance : optional
24722472
Maximum distance between labels of the other object and this
2473-
object for inexact matches.
2473+
object for inexact matches. Can be list-like.
24742474
24752475
.. versionadded:: 0.17.0
2476+
.. versionadded:: 0.21.0 (list-like tolerance)
24762477
24772478
Notes
24782479
-----
@@ -2860,7 +2861,14 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
28602861
matches. The values of the index at the matching locations most
28612862
satisfy the equation ``abs(index[indexer] - target) <= tolerance``.
28622863
2864+
Tolerance may be a scalar value, which applies the same tolerance
2865+
to all values, or list-like, which applies variable tolerance per
2866+
element. List-like includes list, tuple, array, Series, and must be
2867+
the same size as the index and its dtype must exactly match the
2868+
index's type.
2869+
28632870
.. versionadded:: 0.17.0
2871+
.. versionadded:: 0.21.0 (list-like tolerance)
28642872
28652873
Examples
28662874
--------
@@ -3120,7 +3128,14 @@ def _reindex_multi(self, axes, copy, fill_value):
31203128
matches. The values of the index at the matching locations most
31213129
satisfy the equation ``abs(index[indexer] - target) <= tolerance``.
31223130
3131+
Tolerance may be a scalar value, which applies the same tolerance
3132+
to all values, or list-like, which applies variable tolerance per
3133+
element. List-like includes list, tuple, array, Series, and must be
3134+
the same size as the index and its dtype must exactly match the
3135+
index's type.
3136+
31233137
.. versionadded:: 0.17.0
3138+
.. versionadded:: 0.21.0 (list-like tolerance)
31243139
31253140
Examples
31263141
--------

0 commit comments

Comments
 (0)