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

Method skew

dask/dataframe/dask_expr/_collection.py:1683–1739  ·  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

1681
1682 @derived_from(pd.DataFrame)
1683 def skew(
1684 self,
1685 axis=0,
1686 bias=True,
1687 nan_policy="propagate",
1688 numeric_only=False,
1689 ):
1690 """
1691 .. note::
1692
1693 This implementation follows the dask.array.stats implementation
1694 of skewness and calculates skewness without taking into account
1695 a bias term for finite sample size, which corresponds to the
1696 default settings of the scipy.stats skewness calculation. However,
1697 Pandas corrects for this, so the values differ by a factor of
1698 (n * (n - 1)) ** 0.5 / (n - 2), where n is the number of samples.
1699
1700 Further, this method currently does not support filtering out NaN
1701 values, which is again a difference to Pandas.
1702 """
1703 _raise_if_object_series(self, "skew")
1704 if axis is None:
1705 raise ValueError("`axis=None` isn't currently supported for `skew`")
1706 axis = self._validate_axis(axis)
1707
1708 if is_dataframe_like(self):
1709 # Let pandas raise errors if necessary
1710 meta = self._meta_nonempty.skew(axis=axis, numeric_only=numeric_only)
1711 else:
1712 meta = self._meta_nonempty.skew()
1713
1714 if axis == 1:
1715 return self.map_partitions(
1716 M.skew,
1717 meta=meta,
1718 axis=axis,
1719 enforce_metadata=False,
1720 )
1721
1722 if not bias:
1723 raise NotImplementedError("bias=False is not implemented.")
1724 if nan_policy != "propagate":
1725 raise NotImplementedError(
1726 "`nan_policy` other than 'propagate' have not been implemented."
1727 )
1728
1729 frame = self
1730 if frame.ndim > 1:
1731 frame = frame.select_dtypes(
1732 include=["number", "bool"], exclude=[np.timedelta64]
1733 )
1734 m2 = new_collection(Moment(frame, order=2))
1735 m3 = new_collection(Moment(frame, order=3))
1736 result = m3 / m2**1.5
1737 if result.ndim == 1:
1738 result = result.fillna(0.0)
1739 return result
1740

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