Skip to content

Commit 458c9f9

Browse files
sah0725sah0725
andauthored
DOC: clarify that check_array_indexer accepts int and slice (#62573)
Co-authored-by: sah0725 <[email protected]>
1 parent 21130b1 commit 458c9f9

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pandas/core/indexers/utils.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,11 @@ def check_array_indexer(array: AnyArrayLike, indexer: Any) -> Any:
434434
----------
435435
array : array-like
436436
The array that is being indexed (only used for the length).
437-
indexer : array-like or list-like
438-
The array-like that's used to index. List-like input that is not yet
439-
a numpy array or an ExtensionArray is converted to one. Other input
440-
types are passed through as is.
437+
indexer : array-like, list-like, int, slice, or other indexer
438+
The indexer used for indexing. Array-like and list-like inputs that
439+
are not yet a numpy array or an ExtensionArray are converted to one.
440+
Non-array indexers (int, slice, Ellipsis, tuples, etc.) are passed
441+
through as is.
441442
442443
Returns
443444
-------
@@ -486,6 +487,13 @@ def check_array_indexer(array: AnyArrayLike, indexer: Any) -> Any:
486487
>>> pd.api.indexers.check_array_indexer(arr, mask)
487488
array([ True, False])
488489
490+
Integer and slice indexers are passed through as is:
491+
492+
>>> pd.api.indexers.check_array_indexer(arr, 1)
493+
1
494+
>>> pd.api.indexers.check_array_indexer(arr, slice(0, 1, 1))
495+
slice(0, 1, 1)
496+
489497
Similarly for integer indexers, an integer ndarray is returned when it is
490498
a valid indexer, otherwise an error is (for integer indexers, a matching
491499
length is not required):

0 commit comments

Comments
 (0)