MCPcopy
hub / github.com/pandas-dev/pandas / nanstd

Function nanstd

pandas/core/nanops.py:912–955  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

910
911@bottleneck_switch(ddof=1)
912def 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")

Callers

nothing calls this directly

Calls 4

_get_valuesFunction · 0.85
nanvarFunction · 0.85
_wrap_resultsFunction · 0.85
viewMethod · 0.45

Tested by

no test coverage detected