Skip to content

Commit 91245a7

Browse files
authored
DOC: Add proper docstring to maybe_convert_indices
Patches several spelling errors and expands current doc to a proper doc-string.
1 parent 8354a1d commit 91245a7

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

pandas/core/indexing.py

+24-2
Original file line numberDiff line numberDiff line change
@@ -1985,9 +1985,31 @@ def get_indexer(_i, _idx):
19851985

19861986

19871987
def maybe_convert_indices(indices, n):
1988-
""" if we have negative indicies, translate to postive here
1989-
if have indicies that are out-of-bounds, raise an IndexError
19901988
"""
1989+
Attempt to convert indices into valid, positive indices.
1990+
1991+
If we have negative indices, translate to positive here.
1992+
If we have indices that are out-of-bounds, raise an IndexError.
1993+
1994+
Parameters
1995+
----------
1996+
indices : array-like
1997+
The array of indices that we are to convert.
1998+
n : int
1999+
The number of elements in the array that we are indexing.
2000+
2001+
Returns
2002+
-------
2003+
valid_indices : array-like
2004+
An array-like of positive indices that correspond to the ones
2005+
that were passed in initially to this function.
2006+
2007+
Raises
2008+
------
2009+
IndexError : one of the converted indices either exceeded the number
2010+
of elements (specified by `n`) OR was still negative.
2011+
"""
2012+
19912013
if isinstance(indices, list):
19922014
indices = np.array(indices)
19932015
if len(indices) == 0:

0 commit comments

Comments
 (0)