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

Function nankurt

pandas/core/nanops.py:1311–1425  ·  view source on GitHub ↗

Compute the sample excess kurtosis The statistic computed here is the adjusted Fisher-Pearson standardized moment coefficient G2, computed directly from the second and fourth central moment. Parameters ---------- values : ndarray axis : int, optional skipna : b

(
    values: np.ndarray,
    *,
    axis: AxisInt | None = None,
    skipna: bool = True,
    mask: npt.NDArray[np.bool_] | None = None,
)

Source from the content-addressed store, hash-verified

1309@disallow("M8", "m8")
1310@maybe_operate_rowwise
1311def nankurt(
1312 values: np.ndarray,
1313 *,
1314 axis: AxisInt | None = None,
1315 skipna: bool = True,
1316 mask: npt.NDArray[np.bool_] | None = None,
1317) -> float:
1318 """
1319 Compute the sample excess kurtosis
1320
1321 The statistic computed here is the adjusted Fisher-Pearson standardized
1322 moment coefficient G2, computed directly from the second and fourth
1323 central moment.
1324
1325 Parameters
1326 ----------
1327 values : ndarray
1328 axis : int, optional
1329 skipna : bool, default True
1330 mask : ndarray[bool], optional
1331 nan-mask if known
1332
1333 Returns
1334 -------
1335 result : float64
1336 Unless input is a float array, in which case use the same
1337 precision as the input array.
1338
1339 Examples
1340 --------
1341 >>> from pandas.core import nanops
1342 >>> s = pd.Series([1, np.nan, 1, 3, 2])
1343 >>> nanops.nankurt(s.values)
1344 np.float64(-1.2892561983471076)
1345 """
1346 mask = _maybe_get_mask(values, skipna, mask)
1347 if values.dtype.kind != "f":
1348 values = values.astype("f8")
1349 count = _get_counts(values.shape, mask, axis)
1350 else:
1351 count = _get_counts(values.shape, mask, axis, dtype=values.dtype)
1352
1353 if skipna and mask is not None:
1354 values = values.copy()
1355 np.putmask(values, mask, 0)
1356 elif not skipna and mask is not None and mask.any():
1357 return np.nan
1358
1359 with np.errstate(invalid="ignore", divide="ignore"):
1360 mean = values.sum(axis, dtype=np.float64) / count
1361 if axis is not None:
1362 mean = np.expand_dims(mean, axis)
1363
1364 adjusted = values - mean
1365 if skipna and mask is not None:
1366 np.putmask(adjusted, mask, 0)
1367 adjusted2 = adjusted**2
1368 adjusted4 = adjusted2**2

Callers

nothing calls this directly

Calls 12

_maybe_get_maskFunction · 0.85
_get_countsFunction · 0.85
_zero_out_fperrFunction · 0.85
absMethod · 0.80
astypeMethod · 0.45
copyMethod · 0.45
putmaskMethod · 0.45
anyMethod · 0.45
sumMethod · 0.45
maxMethod · 0.45
typeMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected