Skip to content

Commit 5d4b989

Browse files
author
MomIsBestFriend
committed
DOC: Cleaned docstrings
1 parent a2bbdb5 commit 5d4b989

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

pandas/core/indexers.py

+29-24
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ def is_list_like_indexer(key) -> bool:
2727

2828

2929
def is_scalar_indexer(indexer, arr_value) -> bool:
30-
# return True if we are all scalar indexers
31-
30+
"""
31+
Returns
32+
-------
33+
bool
34+
True if we are all scalar indexers.
35+
"""
3236
if arr_value.ndim == 1:
3337
if not isinstance(indexer, tuple):
3438
indexer = tuple([indexer])
@@ -73,21 +77,16 @@ def check_setitem_lengths(indexer, value, values) -> None:
7377
Parameters
7478
----------
7579
indexer : sequence
76-
The key for the setitem
80+
Key for the setitem.
7781
value : array-like
78-
The value for the setitem
82+
Value for the setitem.
7983
values : array-like
80-
The values being set into
81-
82-
Returns
83-
-------
84-
None
84+
Values being set into.
8585
8686
Raises
8787
------
8888
ValueError
89-
When the indexer is an ndarray or list and the lengths don't
90-
match.
89+
When the indexer is an ndarray or list and the lengths don't match.
9190
"""
9291
# boolean with truth values == len of the value is ok too
9392
if isinstance(indexer, (np.ndarray, list)):
@@ -122,7 +121,7 @@ def validate_indices(indices: np.ndarray, n: int) -> None:
122121
----------
123122
indices : ndarray
124123
n : int
125-
length of the array being indexed
124+
Length of the array being indexed.
126125
127126
Raises
128127
------
@@ -144,11 +143,11 @@ def validate_indices(indices: np.ndarray, n: int) -> None:
144143
if len(indices):
145144
min_idx = indices.min()
146145
if min_idx < -1:
147-
raise ValueError(
148-
f"'indices' contains values less than allowed ({min_idx} < -1)"
149-
)
146+
msg = f"'indices' contains values less than allowed ({min_idx} < -1)"
147+
raise ValueError(msg)
150148

151149
max_idx = indices.max()
150+
152151
if max_idx >= n:
153152
raise IndexError("indices are out-of-bounds")
154153

@@ -167,27 +166,27 @@ def maybe_convert_indices(indices, n: int):
167166
Parameters
168167
----------
169168
indices : array-like
170-
The array of indices that we are to convert.
169+
Array of indices that we are to convert.
171170
n : int
172-
The number of elements in the array that we are indexing.
171+
Number of elements in the array that we are indexing.
173172
174173
Returns
175174
-------
176-
valid_indices : array-like
175+
array-like
177176
An array-like of positive indices that correspond to the ones
178177
that were passed in initially to this function.
179178
180179
Raises
181180
------
182-
IndexError : one of the converted indices either exceeded the number
183-
of elements (specified by `n`) OR was still negative.
181+
IndexError
182+
One of the converted indices either exceeded the number of,
183+
elements (specified by `n`), or was still negative.
184184
"""
185-
186185
if isinstance(indices, list):
187186
indices = np.array(indices)
188187
if len(indices) == 0:
189-
# If list is empty, np.array will return float and cause indexing
190-
# errors.
188+
# If `indices` is empty, `np.array` will return a float,
189+
# and will cause indexing errors.
191190
return np.empty(0, dtype=np.intp)
192191

193192
mask = indices < 0
@@ -207,7 +206,13 @@ def maybe_convert_indices(indices, n: int):
207206

208207
def length_of_indexer(indexer, target=None) -> int:
209208
"""
210-
return the length of a single non-tuple indexer which could be a slice
209+
Checks the length of a given indexer.
210+
211+
Returns
212+
-------
213+
int
214+
Length of a single non-tuple indexer,
215+
which could be a slice.
211216
"""
212217
if target is not None and isinstance(indexer, slice):
213218
target_len = len(target)

0 commit comments

Comments
 (0)