Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions pandas/core/indexers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,11 @@ def check_array_indexer(array: AnyArrayLike, indexer: Any) -> Any:
----------
array : array-like
The array that is being indexed (only used for the length).
indexer : array-like or list-like
The array-like that's used to index. List-like input that is not yet
a numpy array or an ExtensionArray is converted to one. Other input
types are passed through as is.
indexer : array-like, list-like, int, slice, or other indexer
The indexer used for indexing. Array-like and list-like inputs that
are not yet a numpy array or an ExtensionArray are converted to one.
Non-array indexers (int, slice, Ellipsis, tuples, etc.) are passed
through as is.

Returns
-------
Expand Down Expand Up @@ -486,6 +487,13 @@ def check_array_indexer(array: AnyArrayLike, indexer: Any) -> Any:
>>> pd.api.indexers.check_array_indexer(arr, mask)
array([ True, False])

Integer and slice indexers are passed through as is:

>>> pd.api.indexers.check_array_indexer(arr, 1)
1
>>> pd.api.indexers.check_array_indexer(arr, slice(0, 1, 1))
slice(0, 1, 1)

Similarly for integer indexers, an integer ndarray is returned when it is
a valid indexer, otherwise an error is (for integer indexers, a matching
length is not required):
Expand Down
Loading