Skip to content

Commit 244f747

Browse files
make series axis parameter docs consistent (#47109)
* make series docs consistent add series unused param info to DF docs * fix trailing whitespace * fix docs build * add unused * add or update docs for all series methods * small fix * fix line length * fix param order * fix param order * add * add backticks to None and fix space Co-authored-by: uncjackg <[email protected]>
1 parent c8ac953 commit 244f747

File tree

9 files changed

+68
-42
lines changed

9 files changed

+68
-42
lines changed

pandas/core/arrays/datetimes.py

+1
Original file line numberDiff line numberDiff line change
@@ -2004,6 +2004,7 @@ def std(
20042004
----------
20052005
axis : int optional, default None
20062006
Axis for the function to be applied on.
2007+
For `Series` this parameter is unused and defaults to `None`.
20072008
ddof : int, default 1
20082009
Degrees of Freedom. The divisor used in calculations is N - ddof,
20092010
where N represents the number of elements.

pandas/core/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def argmax(self, axis=None, skipna: bool = True, *args, **kwargs) -> int:
595595
Parameters
596596
----------
597597
axis : {{None}}
598-
Dummy argument for consistency with Series.
598+
Unused. Parameter needed for compatibility with DataFrame.
599599
skipna : bool, default True
600600
Exclude NA/null values when showing the result.
601601
*args, **kwargs

pandas/core/generic.py

+34-14
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,8 @@ def set_axis(self, labels, axis: Axis = 0, inplace: bool_t = False):
727727
The values for the new index.
728728
729729
axis : %(axes_single_arg)s, default 0
730-
The axis to update. The value 0 identifies the rows%(axis_description_sub)s.
730+
The axis to update. The value 0 identifies the rows. For `Series`
731+
this parameter is unused and defaults to 0.
731732
732733
inplace : bool, default False
733734
Whether to return a new %(klass)s instance.
@@ -807,6 +808,8 @@ def droplevel(self: NDFrameT, level, axis=0) -> NDFrameT:
807808
* 0 or 'index': remove level(s) in column.
808809
* 1 or 'columns': remove level(s) in row.
809810
811+
For `Series` this parameter is unused and defaults to 0.
812+
810813
Returns
811814
-------
812815
{klass}
@@ -875,7 +878,7 @@ def squeeze(self, axis=None):
875878
----------
876879
axis : {0 or 'index', 1 or 'columns', None}, default None
877880
A specific axis to squeeze. By default, all length-1 axes are
878-
squeezed.
881+
squeezed. For `Series` this parameter is unused and defaults to `None`.
879882
880883
Returns
881884
-------
@@ -1063,7 +1066,7 @@ def rename_axis(self, mapper=lib.no_default, **kwargs):
10631066
specify the axis to target with ``mapper``, or ``index``
10641067
and/or ``columns``.
10651068
axis : {0 or 'index', 1 or 'columns'}, default 0
1066-
The axis to rename.
1069+
The axis to rename. For `Series` this parameter is unused and defaults to 0.
10671070
copy : bool, default True
10681071
Also copy underlying data.
10691072
inplace : bool, default False
@@ -3542,6 +3545,7 @@ def take(
35423545
axis : {0 or 'index', 1 or 'columns', None}, default 0
35433546
The axis on which to select elements. ``0`` means that we are
35443547
selecting rows, ``1`` means that we are selecting columns.
3548+
For `Series` this parameter is unused and defaults to 0.
35453549
is_copy : bool
35463550
Before pandas 1.0, ``is_copy=False`` can be specified to ensure
35473551
that the return value is an actual copy. Starting with pandas 1.0,
@@ -5087,8 +5091,8 @@ def filter(
50875091
Keep labels from axis for which re.search(regex, label) == True.
50885092
axis : {0 or ‘index’, 1 or ‘columns’, None}, default None
50895093
The axis to filter on, expressed either as an index (int)
5090-
or axis name (str). By default this is the info axis,
5091-
'index' for Series, 'columns' for DataFrame.
5094+
or axis name (str). By default this is the info axis, 'columns' for
5095+
DataFrame. For `Series` this parameter is unused and defaults to `None`.
50925096
50935097
Returns
50945098
-------
@@ -5372,7 +5376,7 @@ def sample(
53725376
53735377
axis : {0 or ‘index’, 1 or ‘columns’, None}, default None
53745378
Axis to sample. Accepts axis number or name. Default is stat axis
5375-
for given data type (0 for Series and DataFrames).
5379+
for given data type. For `Series` this parameter is unused and defaults to `None`.
53765380
ignore_index : bool, default False
53775381
If True, the resulting index will be labeled 0, 1, …, n - 1.
53785382
@@ -6354,7 +6358,8 @@ def fillna(
63546358
pad / ffill: propagate last valid observation forward to next valid
63556359
backfill / bfill: use next valid observation to fill gap.
63566360
axis : {axes_single_arg}
6357-
Axis along which to fill missing values.
6361+
Axis along which to fill missing values. For `Series`
6362+
this parameter is unused and defaults to 0.
63586363
inplace : bool, default False
63596364
If True, fill in-place. Note: this will modify any
63606365
other views on this object (e.g., a no-copy slice for a column in a
@@ -6830,7 +6835,8 @@ def interpolate(
68306835
scipy 0.18.
68316836
68326837
axis : {{0 or 'index', 1 or 'columns', None}}, default None
6833-
Axis to interpolate along.
6838+
Axis to interpolate along. For `Series` this parameter is unused
6839+
and defaults to 0.
68346840
limit : int, optional
68356841
Maximum number of consecutive NaNs to fill. Must be greater than
68366842
0.
@@ -7477,8 +7483,9 @@ def clip(
74777483
Maximum threshold value. All values above this
74787484
threshold will be set to it. A missing
74797485
threshold (e.g `NA`) will not clip the value.
7480-
axis : int or str axis name, optional
7486+
axis : {{0 or 'index', 1 or 'columns', None}}, default None
74817487
Align object with lower and upper along the given axis.
7488+
For `Series` this parameter is unused and defaults to `None`.
74827489
inplace : bool, default False
74837490
Whether to perform the operation in place on the data.
74847491
*args, **kwargs
@@ -7744,6 +7751,7 @@ def at_time(self: NDFrameT, time, asof: bool_t = False, axis=None) -> NDFrameT:
77447751
----------
77457752
time : datetime.time or str
77467753
axis : {0 or 'index', 1 or 'columns'}, default 0
7754+
For `Series` this parameter is unused and defaults to 0.
77477755
77487756
Returns
77497757
-------
@@ -7830,6 +7838,7 @@ def between_time(
78307838
Include boundaries; whether to set each bound as closed or open.
78317839
axis : {0 or 'index', 1 or 'columns'}, default 0
78327840
Determine range time on index or columns value.
7841+
For `Series` this parameter is unused and defaults to 0.
78337842
78347843
Returns
78357844
-------
@@ -7951,8 +7960,8 @@ def resample(
79517960
rule : DateOffset, Timedelta or str
79527961
The offset string or object representing target conversion.
79537962
axis : {{0 or 'index', 1 or 'columns'}}, default 0
7954-
Which axis to use for up- or down-sampling. For `Series` this
7955-
will default to 0, i.e. along the rows. Must be
7963+
Which axis to use for up- or down-sampling. For `Series` this parameter
7964+
is unused and defaults to 0. Must be
79567965
`DatetimeIndex`, `TimedeltaIndex` or `PeriodIndex`.
79577966
closed : {{'right', 'left'}}, default None
79587967
Which side of bin interval is closed. The default is 'left'
@@ -8521,6 +8530,7 @@ def rank(
85218530
----------
85228531
axis : {0 or 'index', 1 or 'columns'}, default 0
85238532
Index to direct ranking.
8533+
For `Series` this parameter is unused and defaults to 0.
85248534
method : {'average', 'min', 'max', 'first', 'dense'}, default 'average'
85258535
How to rank the group of records that have the same value (i.e. ties):
85268536
@@ -9258,7 +9268,8 @@ def where(
92589268
inplace : bool, default False
92599269
Whether to perform the operation in place on the data.
92609270
axis : int, default None
9261-
Alignment axis if needed.
9271+
Alignment axis if needed. For `Series` this parameter is
9272+
unused and defaults to 0.
92629273
level : int, default None
92639274
Alignment level if needed.
92649275
errors : str, {{'raise', 'ignore'}}, default 'raise'
@@ -9443,7 +9454,7 @@ def shift(
94439454
the freq or inferred_freq attributes of the index. If neither of
94449455
those attributes exist, a ValueError is thrown.
94459456
axis : {{0 or 'index', 1 or 'columns', None}}, default None
9446-
Shift direction.
9457+
Shift direction. For `Series` this parameter is unused and defaults to 0.
94479458
fill_value : object, optional
94489459
The scalar value to use for newly introduced missing values.
94499460
the default depends on the dtype of `self`.
@@ -9577,6 +9588,8 @@ def slice_shift(self: NDFrameT, periods: int = 1, axis=0) -> NDFrameT:
95779588
----------
95789589
periods : int
95799590
Number of periods to move, can be positive or negative.
9591+
axis : {0 or 'index', 1 or 'columns', None}, default 0
9592+
For `Series` this parameter is unused and defaults to 0.
95809593
95819594
Returns
95829595
-------
@@ -9628,6 +9641,7 @@ def tshift(self: NDFrameT, periods: int = 1, freq=None, axis: Axis = 0) -> NDFra
96289641
or time rule expressed as a string (e.g. 'EOM').
96299642
axis : {0 or ‘index’, 1 or ‘columns’, None}, default 0
96309643
Corresponds to the axis that contains the Index.
9644+
For `Series` this parameter is unused and defaults to 0.
96319645
96329646
Returns
96339647
-------
@@ -9670,6 +9684,7 @@ def truncate(
96709684
Truncate all rows after this index value.
96719685
axis : {0 or 'index', 1 or 'columns'}, optional
96729686
Axis to truncate. Truncates the index (rows) by default.
9687+
For `Series` this parameter is unused and defaults to 0.
96739688
copy : bool, default is True,
96749689
Return a copy of the truncated section.
96759690
@@ -10893,6 +10908,7 @@ def mad(
1089310908
----------
1089410909
axis : {axis_descr}
1089510910
Axis for the function to be applied on.
10911+
For `Series` this parameter is unused and defaults to 0.
1089610912
skipna : bool, default True
1089710913
Exclude NA/null values when computing the result.
1089810914
level : int or level name, default None
@@ -11551,6 +11567,7 @@ def _doc_params(cls):
1155111567
----------
1155211568
axis : {axis_descr}
1155311569
Axis for the function to be applied on.
11570+
For `Series` this parameter is unused and defaults to 0.
1155411571
skipna : bool, default True
1155511572
Exclude NA/null values when computing the result.
1155611573
level : int or level name, default None
@@ -11581,6 +11598,7 @@ def _doc_params(cls):
1158111598
Parameters
1158211599
----------
1158311600
axis : {axis_descr}
11601+
For `Series` this parameter is unused and defaults to 0.
1158411602
skipna : bool, default True
1158511603
Exclude NA/null values. If an entire row/column is NA, the result
1158611604
will be NA.
@@ -11672,7 +11690,8 @@ def _doc_params(cls):
1167211690
Parameters
1167311691
----------
1167411692
axis : {{0 or 'index', 1 or 'columns', None}}, default 0
11675-
Indicate which axis or axes should be reduced.
11693+
Indicate which axis or axes should be reduced. For `Series` this parameter
11694+
is unused and defaults to 0.
1167611695
1167711696
* 0 / 'index' : reduce the index, return a Series whose index is the
1167811697
original column labels.
@@ -11774,6 +11793,7 @@ def _doc_params(cls):
1177411793
----------
1177511794
axis : {{0 or 'index', 1 or 'columns'}}, default 0
1177611795
The index or the name of the axis. 0 is equivalent to None or 'index'.
11796+
For `Series` this parameter is unused and defaults to 0.
1177711797
skipna : bool, default True
1177811798
Exclude NA/null values. If an entire row/column is NA, the result
1177911799
will be NA.

pandas/core/ops/docstrings.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -428,14 +428,16 @@ def make_flex_doc(op_name: str, typ: str) -> str:
428428
Parameters
429429
----------
430430
other : Series or scalar value
431+
level : int or name
432+
Broadcast across a level, matching Index values on the
433+
passed MultiIndex level.
431434
fill_value : None or float value, default None (NaN)
432435
Fill existing missing (NaN) values, and any new element needed for
433436
successful Series alignment, with this value before computation.
434437
If data in both corresponding Series locations is missing
435438
the result of filling (at that location) will be missing.
436-
level : int or name
437-
Broadcast across a level, matching Index values on the
438-
passed MultiIndex level.
439+
axis : {{0 or 'index'}}
440+
Unused. Parameter needed for compatibility with DataFrame.
439441
440442
Returns
441443
-------
@@ -462,7 +464,7 @@ def make_flex_doc(op_name: str, typ: str) -> str:
462464
other : scalar, sequence, Series, or DataFrame
463465
Any single or multiple element data structure, or list-like object.
464466
axis : {{0 or 'index', 1 or 'columns'}}
465-
Whether to compare by the index (0 or 'index') or columns
467+
Whether to compare by the index (0 or 'index') or columns.
466468
(1 or 'columns'). For Series input, axis to match Series index on.
467469
level : int or label
468470
Broadcast across a level, matching Index values on the

pandas/core/series.py

+18-22
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
"klass": "Series",
172172
"axes_single_arg": "{0 or 'index'}",
173173
"axis": """axis : {0 or 'index'}
174-
Parameter needed for compatibility with DataFrame.""",
174+
Unused. Parameter needed for compatibility with DataFrame.""",
175175
"inplace": """inplace : bool, default False
176176
If True, performs operation inplace and returns None.""",
177177
"unique": "np.ndarray",
@@ -1322,8 +1322,7 @@ def repeat(self, repeats, axis=None) -> Series:
13221322
non-negative integer. Repeating 0 times will return an empty
13231323
Series.
13241324
axis : None
1325-
Must be ``None``. Has no effect but is accepted for compatibility
1326-
with numpy.
1325+
Unused. Parameter needed for compatibility with DataFrame.
13271326
13281327
Returns
13291328
-------
@@ -2309,9 +2308,8 @@ def idxmin(self, axis=0, skipna=True, *args, **kwargs):
23092308
23102309
Parameters
23112310
----------
2312-
axis : int, default 0
2313-
For compatibility with DataFrame.idxmin. Redundant for application
2314-
on Series.
2311+
axis : {0 or 'index'}
2312+
Unused. Parameter needed for compatibility with DataFrame.
23152313
skipna : bool, default True
23162314
Exclude NA/null values. If the entire Series is NA, the result
23172315
will be NA.
@@ -2378,9 +2376,8 @@ def idxmax(self, axis=0, skipna=True, *args, **kwargs):
23782376
23792377
Parameters
23802378
----------
2381-
axis : int, default 0
2382-
For compatibility with DataFrame.idxmax. Redundant for application
2383-
on Series.
2379+
axis : {0 or 'index'}
2380+
Unused. Parameter needed for compatibility with DataFrame.
23842381
skipna : bool, default True
23852382
Exclude NA/null values. If the entire Series is NA, the result
23862383
will be NA.
@@ -3391,9 +3388,8 @@ def sort_values(
33913388
33923389
Parameters
33933390
----------
3394-
axis : {0 or 'index'}, default 0
3395-
Axis to direct sorting. The value 'index' is accepted for
3396-
compatibility with DataFrame.sort_values.
3391+
axis : {0 or 'index'}
3392+
Unused. Parameter needed for compatibility with DataFrame.
33973393
ascending : bool or list of bools, default True
33983394
If True, sort values in ascending order, otherwise descending.
33993395
inplace : bool, default False
@@ -3652,8 +3648,8 @@ def sort_index( # type: ignore[override]
36523648
36533649
Parameters
36543650
----------
3655-
axis : int, default 0
3656-
Axis to direct sorting. This can only be 0 for Series.
3651+
axis : {0 or 'index'}
3652+
Unused. Parameter needed for compatibility with DataFrame.
36573653
level : int, optional
36583654
If not None, sort on values in specified index level(s).
36593655
ascending : bool or list-like of bools, default True
@@ -3800,8 +3796,8 @@ def argsort(self, axis=0, kind="quicksort", order=None) -> Series:
38003796
38013797
Parameters
38023798
----------
3803-
axis : {0 or "index"}
3804-
Has no effect but is accepted for compatibility with numpy.
3799+
axis : {0 or 'index'}
3800+
Unused. Parameter needed for compatibility with DataFrame.
38053801
kind : {'mergesort', 'quicksort', 'heapsort', 'stable'}, default 'quicksort'
38063802
Choice of sorting algorithm. See :func:`numpy.sort` for more
38073803
information. 'mergesort' and 'stable' are the only stable algorithms.
@@ -4718,8 +4714,8 @@ def rename(
47184714
47194715
Parameters
47204716
----------
4721-
axis : {0 or "index"}
4722-
Unused. Accepted for compatibility with DataFrame method only.
4717+
axis : {0 or 'index'}
4718+
Unused. Parameter needed for compatibility with DataFrame.
47234719
index : scalar, hashable sequence, dict-like or function, optional
47244720
Functions or dict-like are transformations to apply to
47254721
the index.
@@ -4916,8 +4912,8 @@ def drop( # type: ignore[override]
49164912
----------
49174913
labels : single label or list-like
49184914
Index labels to drop.
4919-
axis : 0, default 0
4920-
Redundant for application on Series.
4915+
axis : {0 or 'index'}
4916+
Unused. Parameter needed for compatibility with DataFrame.
49214917
index : single label or list-like
49224918
Redundant for application on Series, but 'index' can be used instead
49234919
of 'labels'.
@@ -5531,8 +5527,8 @@ def dropna(self, axis=0, inplace=False, how=None):
55315527
55325528
Parameters
55335529
----------
5534-
axis : {0 or 'index'}, default 0
5535-
There is only one axis to drop values from.
5530+
axis : {0 or 'index'}
5531+
Unused. Parameter needed for compatibility with DataFrame.
55365532
inplace : bool, default False
55375533
If True, do operation inplace and return None.
55385534
how : str, optional

pandas/core/shared_docs.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@
101101
of labels may be passed to group by the columns in ``self``.
102102
Notice that a tuple is interpreted as a (single) key.
103103
axis : {0 or 'index', 1 or 'columns'}, default 0
104-
Split along rows (0) or columns (1).
104+
Split along rows (0) or columns (1). For `Series` this parameter
105+
is unused and defaults to 0.
105106
level : int, level name, or sequence of such, default None
106107
If the axis is a MultiIndex (hierarchical), group by a particular
107108
level or levels.

pandas/core/window/ewm.py

+2
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ class ExponentialMovingWindow(BaseWindow):
211211
212212
If ``1`` or ``'columns'``, calculate across the columns.
213213
214+
For `Series` this parameter is unused and defaults to 0.
215+
214216
times : str, np.ndarray, Series, default None
215217
216218
.. versionadded:: 1.1.0

0 commit comments

Comments
 (0)