Compute the standard deviation along given axis while ignoring NaNs Parameters ---------- values : ndarray axis : int, optional skipna : bool, default True ddof : int, default 1 Delta Degrees of Freedom. The divisor used in calculations is N - ddof, wher
(
values,
*,
axis: AxisInt | None = None,
skipna: bool = True,
ddof: int = 1,
mask=None,
)
| 910 | |
| 911 | @bottleneck_switch(ddof=1) |
| 912 | def nanstd( |
| 913 | values, |
| 914 | *, |
| 915 | axis: AxisInt | None = None, |
| 916 | skipna: bool = True, |
| 917 | ddof: int = 1, |
| 918 | mask=None, |
| 919 | ): |
| 920 | """ |
| 921 | Compute the standard deviation along given axis while ignoring NaNs |
| 922 | |
| 923 | Parameters |
| 924 | ---------- |
| 925 | values : ndarray |
| 926 | axis : int, optional |
| 927 | skipna : bool, default True |
| 928 | ddof : int, default 1 |
| 929 | Delta Degrees of Freedom. The divisor used in calculations is N - ddof, |
| 930 | where N represents the number of elements. |
| 931 | mask : ndarray[bool], optional |
| 932 | nan-mask if known |
| 933 | |
| 934 | Returns |
| 935 | ------- |
| 936 | result : float |
| 937 | Unless input is a float array, in which case use the same |
| 938 | precision as the input array. |
| 939 | |
| 940 | Examples |
| 941 | -------- |
| 942 | >>> from pandas.core import nanops |
| 943 | >>> s = pd.Series([1, np.nan, 2, 3]) |
| 944 | >>> nanops.nanstd(s.values) |
| 945 | 1.0 |
| 946 | """ |
| 947 | if values.dtype.kind == "M": |
| 948 | unit = np.datetime_data(values.dtype)[0] |
| 949 | values = values.view(f"m8[{unit}]") |
| 950 | |
| 951 | orig_dtype = values.dtype |
| 952 | values, mask = _get_values(values, skipna, mask=mask) |
| 953 | |
| 954 | result = np.sqrt(nanvar(values, axis=axis, skipna=skipna, ddof=ddof, mask=mask)) |
| 955 | return _wrap_results(result, orig_dtype) |
| 956 | |
| 957 | |
| 958 | @disallow("M8", "m8") |
nothing calls this directly
no test coverage detected