Skip to content

Commit 65860fa

Browse files
authored
CLN: docstring cleanup (#40713)
1 parent e6f7e7b commit 65860fa

File tree

19 files changed

+68
-55
lines changed

19 files changed

+68
-55
lines changed

pandas/_libs/groupby.pyx

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ def group_cumprod_float64(float64_t[:, ::1] out,
154154
155155
Parameters
156156
----------
157-
out : float64 array
157+
out : np.ndarray[np.float64, ndim=2]
158158
Array to store cumprod in.
159-
values : float64 array
159+
values : np.ndarray[np.float64, ndim=2]
160160
Values to take cumprod of.
161161
labels : np.ndarray[np.intp]
162162
Labels to group by.
@@ -211,9 +211,9 @@ def group_cumsum(numeric[:, ::1] out,
211211
212212
Parameters
213213
----------
214-
out : array
214+
out : np.ndarray[ndim=2]
215215
Array to store cumsum in.
216-
values : array
216+
values : np.ndarray[ndim=2]
217217
Values to take cumsum of.
218218
labels : np.ndarray[np.intp]
219219
Labels to group by.
@@ -329,12 +329,15 @@ def group_fillna_indexer(ndarray[int64_t] out, ndarray[intp_t] labels,
329329
330330
Parameters
331331
----------
332-
out : array of int64_t values which this method will write its results to
333-
Missing values will be written to with a value of -1
332+
out : np.ndarray[np.uint8]
333+
Values into which this method will write its results.
334334
labels : np.ndarray[np.intp]
335335
Array containing unique label for each group, with its ordering
336336
matching up to the corresponding record in `values`.
337-
mask : array of int64_t values where a 1 indicates a missing value
337+
values : np.ndarray[np.uint8]
338+
Containing the truth value of each element.
339+
mask : np.ndarray[np.uint8]
340+
Indicating whether a value is na or not.
338341
direction : {'ffill', 'bfill'}
339342
Direction for fill to be applied (forwards or backwards, respectively)
340343
limit : Consecutive values to fill before stopping, or -1 for no limit
@@ -396,12 +399,15 @@ def group_any_all(uint8_t[::1] out,
396399
397400
Parameters
398401
----------
399-
out : array of values which this method will write its results to
402+
out : np.ndarray[np.uint8]
403+
Values into which this method will write its results.
400404
labels : np.ndarray[np.intp]
401405
Array containing unique label for each group, with its
402406
ordering matching up to the corresponding record in `values`
403-
values : array containing the truth value of each element
404-
mask : array indicating whether a value is na or not
407+
values : np.ndarray[np.uint8]
408+
Containing the truth value of each element.
409+
mask : np.ndarray[np.uint8]
410+
Indicating whether a value is na or not.
405411
val_test : {'any', 'all'}
406412
String object dictating whether to use any or all truth testing
407413
skipna : bool
@@ -721,14 +727,17 @@ def group_quantile(ndarray[float64_t] out,
721727
722728
Parameters
723729
----------
724-
out : ndarray
730+
out : np.ndarray[np.float64]
725731
Array of aggregated values that will be written to.
732+
values : np.ndarray
733+
Array containing the values to apply the function against.
726734
labels : ndarray[np.intp]
727735
Array containing the unique group labels.
728736
values : ndarray
729737
Array containing the values to apply the function against.
730738
q : float
731739
The quantile value to search for.
740+
interpolation : {'linear', 'lower', 'highest', 'nearest', 'midpoint'}
732741
733742
Notes
734743
-----
@@ -1048,8 +1057,9 @@ def group_rank(float64_t[:, ::1] out,
10481057
10491058
Parameters
10501059
----------
1051-
out : array of float64_t values which this method will write its results to
1052-
values : array of rank_t values to be ranked
1060+
out : np.ndarray[np.float64, ndim=2]
1061+
Values to which this method will write its results.
1062+
values : np.ndarray of rank_t values to be ranked
10531063
labels : np.ndarray[np.intp]
10541064
Array containing unique label for each group, with its ordering
10551065
matching up to the corresponding record in `values`
@@ -1058,8 +1068,7 @@ def group_rank(float64_t[:, ::1] out,
10581068
groupby functions.
10591069
is_datetimelike : bool
10601070
True if `values` contains datetime-like entries.
1061-
ties_method : {'average', 'min', 'max', 'first', 'dense'}, default
1062-
'average'
1071+
ties_method : {'average', 'min', 'max', 'first', 'dense'}, default 'average'
10631072
* average: average rank of group
10641073
* min: lowest rank in group
10651074
* max: highest rank in group
@@ -1120,9 +1129,9 @@ cdef group_min_max(groupby_t[:, ::1] out,
11201129
11211130
Parameters
11221131
----------
1123-
out : array
1132+
out : np.ndarray[groupby_t, ndim=2]
11241133
Array to store result in.
1125-
counts : int64 array
1134+
counts : np.ndarray[int64]
11261135
Input as a zeroed array, populated by group sizes during algorithm
11271136
values : array
11281137
Values to find column-wise min/max of.
@@ -1241,9 +1250,9 @@ def group_cummin_max(groupby_t[:, ::1] out,
12411250
12421251
Parameters
12431252
----------
1244-
out : array
1253+
out : np.ndarray[groupby_t, ndim=2]
12451254
Array to store cummin/max in.
1246-
values : array
1255+
values : np.ndarray[groupby_t, ndim=2]
12471256
Values to take cummin/max of.
12481257
labels : np.ndarray[np.intp]
12491258
Labels to group by.

pandas/_libs/internals.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def get_blkno_indexers(int64_t[:] blknos, bint group=True):
385385
386386
Returns
387387
-------
388-
iter : iterator of (int, slice or array)
388+
list[tuple[int, slice | np.ndarray]]
389389
"""
390390
# There's blkno in this function's name because it's used in block &
391391
# blockno handling.

pandas/_libs/lib.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ def indices_fast(ndarray[intp_t] index, const int64_t[:] labels, list keys,
916916
"""
917917
Parameters
918918
----------
919-
index : ndarray
919+
index : ndarray[intp]
920920
labels : ndarray[int64]
921921
keys : list
922922
sorted_labels : list[ndarray[int64]]

pandas/_libs/reshape.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def unstack(reshape_t[:, :] values, const uint8_t[:] mask,
5252
stride : int
5353
length : int
5454
width : int
55-
new_values : typed ndarray
55+
new_values : np.ndarray[bool]
5656
result array
5757
new_mask : np.ndarray[bool]
5858
result mask

pandas/_libs/tslibs/conversion.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def datetime_to_datetime64(ndarray[object] values):
316316
317317
Returns
318318
-------
319-
result : ndarray[int64_t]
319+
result : ndarray[datetime64ns]
320320
inferred_tz : tzinfo or None
321321
"""
322322
cdef:

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ def array_to_timedelta64(ndarray[object] values, str unit=None, str errors="rais
315315
"""
316316
Convert an ndarray to an array of timedeltas. If errors == 'coerce',
317317
coerce non-convertible objects to NaT. Otherwise, raise.
318+
319+
Returns
320+
-------
321+
np.ndarray[timedelta64ns]
318322
"""
319323

320324
cdef:

pandas/core/algorithms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ def duplicated(values: ArrayLike, keep: Union[str, bool] = "first") -> np.ndarra
943943
944944
Returns
945945
-------
946-
duplicated : ndarray
946+
duplicated : ndarray[bool]
947947
"""
948948
values, _ = _ensure_data(values)
949949
ndtype = values.dtype.name
@@ -1631,7 +1631,7 @@ def diff(arr, n: int, axis: int = 0, stacklevel=3):
16311631
number of periods
16321632
axis : {0, 1}
16331633
axis to shift on
1634-
stacklevel : int
1634+
stacklevel : int, default 3
16351635
The stacklevel for the lost dtype warning.
16361636
16371637
Returns

pandas/core/arrays/categorical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ def isna(self):
14521452
14531453
Returns
14541454
-------
1455-
a boolean array of whether my values are null
1455+
np.ndarray[bool] of whether my values are null
14561456
14571457
See Also
14581458
--------
@@ -1474,7 +1474,7 @@ def notna(self):
14741474
14751475
Returns
14761476
-------
1477-
a boolean array of whether my values are not null
1477+
np.ndarray[bool] of whether my values are not null
14781478
14791479
See Also
14801480
--------

pandas/core/arrays/datetimes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ def to_pydatetime(self) -> np.ndarray:
10311031
10321032
Returns
10331033
-------
1034-
datetimes : ndarray
1034+
datetimes : ndarray[object]
10351035
"""
10361036
return ints_to_pydatetime(self.asi8, tz=self.tz)
10371037

pandas/core/arrays/timedeltas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ def to_pytimedelta(self) -> np.ndarray:
853853
854854
Returns
855855
-------
856-
datetimes : ndarray
856+
timedeltas : ndarray[object]
857857
"""
858858
return tslibs.ints_to_pytimedelta(self.asi8)
859859

0 commit comments

Comments
 (0)