MCPcopy Create free account
hub / github.com/dask/dask / skew

Method skew

dask/dataframe/dask_expr/_collection.py:1643–1699  ·  view source on GitHub ↗

.. note:: This implementation follows the dask.array.stats implementation of skewness and calculates skewness without taking into account a bias term for finite sample size, which corresponds to the default settings of the scipy.stats skewness ca

(
        self,
        axis=0,
        bias=True,
        nan_policy="propagate",
        numeric_only=False,
    )

Source from the content-addressed store, hash-verified

1641
1642 @derived_from(pd.DataFrame)
1643 def skew(
1644 self,
1645 axis=0,
1646 bias=True,
1647 nan_policy="propagate",
1648 numeric_only=False,
1649 ):
1650 """
1651 .. note::
1652
1653 This implementation follows the dask.array.stats implementation
1654 of skewness and calculates skewness without taking into account
1655 a bias term for finite sample size, which corresponds to the
1656 default settings of the scipy.stats skewness calculation. However,
1657 Pandas corrects for this, so the values differ by a factor of
1658 (n * (n - 1)) ** 0.5 / (n - 2), where n is the number of samples.
1659
1660 Further, this method currently does not support filtering out NaN
1661 values, which is again a difference to Pandas.
1662 """
1663 _raise_if_object_series(self, "skew")
1664 if axis is None:
1665 raise ValueError("`axis=None` isn't currently supported for `skew`")
1666 axis = self._validate_axis(axis)
1667
1668 if is_dataframe_like(self):
1669 # Let pandas raise errors if necessary
1670 meta = self._meta_nonempty.skew(axis=axis, numeric_only=numeric_only)
1671 else:
1672 meta = self._meta_nonempty.skew()
1673
1674 if axis == 1:
1675 return self.map_partitions(
1676 M.skew,
1677 meta=meta,
1678 axis=axis,
1679 enforce_metadata=False,
1680 )
1681
1682 if not bias:
1683 raise NotImplementedError("bias=False is not implemented.")
1684 if nan_policy != "propagate":
1685 raise NotImplementedError(
1686 "`nan_policy` other than 'propagate' have not been implemented."
1687 )
1688
1689 frame = self
1690 if frame.ndim > 1:
1691 frame = frame.select_dtypes(
1692 include=["number", "bool"], exclude=[np.timedelta64]
1693 )
1694 m2 = new_collection(Moment(frame, order=2))
1695 m3 = new_collection(Moment(frame, order=3))
1696 result = m3 / m2**1.5
1697 if result.ndim == 1:
1698 result = result.fillna(0.0)
1699 return result
1700

Callers

nothing calls this directly

Calls 8

map_partitionsMethod · 0.95
_raise_if_object_seriesFunction · 0.90
new_collectionFunction · 0.90
MomentClass · 0.90
is_dataframe_likeFunction · 0.85
select_dtypesMethod · 0.80
_validate_axisMethod · 0.45
fillnaMethod · 0.45

Tested by

no test coverage detected