Skip to content

Commit 0e0c720

Browse files
DOC: add PR01,RT03,SA01 for pandas.DataFrame.std
1 parent 02708ed commit 0e0c720

File tree

1 file changed

+75
-1
lines changed

1 file changed

+75
-1
lines changed

pandas/core/frame.py

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12116,7 +12116,6 @@ def std(
1211612116
) -> Series | Any: ...
1211712117

1211812118
@deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="std")
12119-
@doc(make_doc("std", ndim=2))
1212012119
def std(
1212112120
self,
1212212121
axis: Axis | None = 0,
@@ -12125,6 +12124,81 @@ def std(
1212512124
numeric_only: bool = False,
1212612125
**kwargs,
1212712126
) -> Series | Any:
12127+
"""
12128+
Return sample standard deviation over requested axis.
12129+
12130+
Normalized by N-1 by default. This can be changed using the ddof argument.
12131+
12132+
Parameters
12133+
----------
12134+
axis : {index (0), columns (1)}
12135+
For `Series` this parameter is unused and defaults to 0.
12136+
12137+
.. warning::
12138+
12139+
The behavior of DataFrame.std with ``axis=None`` is deprecated,
12140+
in a future version this will reduce over both axes and return a scalar
12141+
To retain the old behavior, pass axis=0 (or do not pass axis).
12142+
12143+
skipna : bool, default True
12144+
Exclude NA/null values. If an entire row/column is NA, the result
12145+
will be NA.
12146+
ddof : int, default 1
12147+
Delta Degrees of Freedom. The divisor used in calculations is N - ddof,
12148+
where N represents the number of elements.
12149+
numeric_only : bool, default False
12150+
Include only float, int, boolean columns. Not implemented for Series.
12151+
**kwargs : dict
12152+
Parameters to accommodate numpy arguments.
12153+
12154+
Returns
12155+
-------
12156+
Series or DataFrame (if level specified)
12157+
Standard deviation over requested axis.
12158+
12159+
See Also
12160+
--------
12161+
DataFrame.mean : Return the mean of the values over the requested axis.
12162+
DataFrame.mediam : Return the mediam of the values over the requested axis.
12163+
DataFrame.mode : Get the mode(s) of each element along the requested axis.
12164+
DataFrame.sum : Return the sum of the values over the requested axis.
12165+
12166+
Notes
12167+
-----
12168+
To have the same behaviour as `numpy.std`, use `ddof=0` (instead of the
12169+
default `ddof=1`)
12170+
12171+
Examples
12172+
--------
12173+
>>> df = pd.DataFrame(
12174+
... {
12175+
... "person_id": [0, 1, 2, 3],
12176+
... "age": [21, 25, 62, 43],
12177+
... "height": [1.61, 1.87, 1.49, 2.01],
12178+
... }
12179+
... ).set_index("person_id")
12180+
>>> df
12181+
age height
12182+
person_id
12183+
0 21 1.61
12184+
1 25 1.87
12185+
2 62 1.49
12186+
3 43 2.01
12187+
12188+
The standard deviation of the columns can be found as follows:
12189+
12190+
>>> df.std()
12191+
age 18.786076
12192+
height 0.237417
12193+
dtype: float64
12194+
12195+
Alternatively, `ddof=0` can be set to normalize by N instead of N-1:
12196+
12197+
>>> df.std(ddof=0)
12198+
age 16.269219
12199+
height 0.205609
12200+
dtype: float64
12201+
"""
1212812202
result = super().std(
1212912203
axis=axis, skipna=skipna, ddof=ddof, numeric_only=numeric_only, **kwargs
1213012204
)

0 commit comments

Comments
 (0)