Skip to content

Commit 65860fa

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

19 files changed

+68
-55
lines changed

pandas/_libs/groupby.pyx

+28-19
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+4
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

+2-2
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

+2-2
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

+1-1
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

+1-1
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

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8191,7 +8191,7 @@ def _gotitem(
81918191
Parameters
81928192
----------
81938193
key : string / list of selections
8194-
ndim : 1,2
8194+
ndim : {1, 2}
81958195
requested ndim of result
81968196
subset : object, default None
81978197
subset to act on

pandas/core/generic.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -1656,9 +1656,9 @@ def _is_label_reference(self, key, axis=0) -> bool_t:
16561656
16571657
Parameters
16581658
----------
1659-
key: str
1659+
key : str
16601660
Potential label name
1661-
axis: int, default 0
1661+
axis : int, default 0
16621662
Axis perpendicular to the axis that labels are associated with
16631663
(0 means search for column labels, 1 means search for index labels)
16641664
@@ -1687,14 +1687,14 @@ def _is_label_or_level_reference(self, key: str, axis: int = 0) -> bool_t:
16871687
16881688
Parameters
16891689
----------
1690-
key: str
1690+
key : str
16911691
Potential label or level name
1692-
axis: int, default 0
1692+
axis : int, default 0
16931693
Axis that levels are associated with (0 for index, 1 for columns)
16941694
16951695
Returns
16961696
-------
1697-
is_label_or_level: bool
1697+
bool
16981698
"""
16991699
return self._is_level_reference(key, axis=axis) or self._is_label_reference(
17001700
key, axis=axis
@@ -1710,9 +1710,9 @@ def _check_label_or_level_ambiguity(self, key, axis: int = 0) -> None:
17101710
17111711
Parameters
17121712
----------
1713-
key: str or object
1713+
key : str or object
17141714
Label or level name.
1715-
axis: int, default 0
1715+
axis : int, default 0
17161716
Axis that levels are associated with (0 for index, 1 for columns).
17171717
17181718
Raises
@@ -1760,14 +1760,14 @@ def _get_label_or_level_values(self, key: str, axis: int = 0) -> np.ndarray:
17601760
17611761
Parameters
17621762
----------
1763-
key: str
1763+
key : str
17641764
Label or level name.
1765-
axis: int, default 0
1765+
axis : int, default 0
17661766
Axis that levels are associated with (0 for index, 1 for columns)
17671767
17681768
Returns
17691769
-------
1770-
values: np.ndarray
1770+
values : np.ndarray
17711771
17721772
Raises
17731773
------

pandas/core/groupby/categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def recode_for_groupby(
4141
4242
Returns
4343
-------
44-
New Categorical
44+
Categorical
4545
If sort=False, the new categories are set to the order of
4646
appearance in codes (unless ordered=True, in which case the
4747
original order is preserved), followed by any unrepresented

pandas/core/groupby/ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ class BinGrouper(BaseGrouper):
808808
binlabels : the label list
809809
filter_empty : bool, default False
810810
mutated : bool, default False
811-
indexer : a intp array
811+
indexer : np.ndarray[np.intp]
812812
813813
Examples
814814
--------

pandas/core/indexes/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2412,7 +2412,7 @@ def isna(self) -> np.ndarray:
24122412
24132413
Returns
24142414
-------
2415-
numpy.ndarray
2415+
numpy.ndarray[bool]
24162416
A boolean array of whether my values are NA.
24172417
24182418
See Also
@@ -2470,7 +2470,7 @@ def notna(self) -> np.ndarray:
24702470
24712471
Returns
24722472
-------
2473-
numpy.ndarray
2473+
numpy.ndarray[bool]
24742474
Boolean array to indicate which entries are not NA.
24752475
24762476
See Also
@@ -5499,7 +5499,7 @@ def isin(self, values, level=None):
54995499
55005500
Returns
55015501
-------
5502-
is_contained : ndarray
5502+
is_contained : ndarray[bool]
55035503
NumPy array of boolean values.
55045504
55055505
See Also

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3999,7 +3999,7 @@ def _gotitem(self, key, ndim, subset=None) -> Series:
39993999
Parameters
40004000
----------
40014001
key : string / list of selections
4002-
ndim : 1,2
4002+
ndim : {1, 2}
40034003
Requested ndim of result.
40044004
subset : object, default None
40054005
Subset to act on.

pandas/core/tools/datetimes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ def _adjust_to_origin(arg, origin, unit):
576576
date to be adjusted
577577
origin : 'julian' or Timestamp
578578
origin offset for the arg
579-
unit : string
579+
unit : str
580580
passed unit from to_datetime, must be 'D'
581581
582582
Returns

pandas/core/window/rolling.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def _gotitem(self, key, ndim, subset=None):
239239
Parameters
240240
----------
241241
key : str / list of selections
242-
ndim : 1,2
242+
ndim : {1, 2}
243243
requested ndim of result
244244
subset : object, default None
245245
subset to act on

pandas/io/formats/excel.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -431,21 +431,21 @@ class ExcelFormatter:
431431
----------
432432
df : DataFrame or Styler
433433
na_rep: na representation
434-
float_format : string, default None
435-
Format string for floating point numbers
434+
float_format : str, default None
435+
Format string for floating point numbers
436436
cols : sequence, optional
437437
Columns to write
438438
header : bool or sequence of str, default True
439439
Write out column names. If a list of string is given it is
440440
assumed to be aliases for the column names
441441
index : bool, default True
442442
output row names (index)
443-
index_label : string or sequence, default None
444-
Column label for index column(s) if desired. If None is given, and
445-
`header` and `index` are True, then the index names are used. A
446-
sequence should be given if the DataFrame uses MultiIndex.
443+
index_label : str or sequence, default None
444+
Column label for index column(s) if desired. If None is given, and
445+
`header` and `index` are True, then the index names are used. A
446+
sequence should be given if the DataFrame uses MultiIndex.
447447
merge_cells : bool, default False
448-
Format MultiIndex and Hierarchical Rows as merged cells.
448+
Format MultiIndex and Hierarchical Rows as merged cells.
449449
inf_rep : str, default `'inf'`
450450
representation for np.inf values (which aren't representable in Excel)
451451
A `'-'` sign will be added in front of -inf.

0 commit comments

Comments
 (0)