pandas.core.groupby.DataFrameGroupBy.skew#

DataFrameGroupBy.skew(skipna=True, numeric_only=False, **kwargs)[source]#

Return unbiased skew within groups.

Normalized by N-1.

Parameters:
skipnabool, default True

Exclude NA/null values when computing the result.

numeric_onlybool, default False

Include only float, int, boolean columns.

**kwargs

Additional keyword arguments to be passed to the function.

Returns:
DataFrame

Unbiased skew within groups.

See also

DataFrame.skew

Return unbiased skew over requested axis.

Examples

>>> arrays = [
...     ["falcon", "parrot", "cockatoo", "kiwi", "lion", "monkey", "rabbit"],
...     ["bird", "bird", "bird", "bird", "mammal", "mammal", "mammal"],
... ]
>>> index = pd.MultiIndex.from_arrays(arrays, names=("name", "class"))
>>> df = pd.DataFrame(
...     {"max_speed": [389.0, 24.0, 70.0, np.nan, 80.5, 21.5, 15.0]},
...     index=index,
... )
>>> df
                max_speed
name     class
falcon   bird        389.0
parrot   bird         24.0
cockatoo bird         70.0
kiwi     bird          NaN
lion     mammal       80.5
monkey   mammal       21.5
rabbit   mammal       15.0
>>> gb = df.groupby(["class"])
>>> gb.skew()
        max_speed
class
bird     1.628296
mammal   1.669046
>>> gb.skew(skipna=False)
        max_speed
class
bird          NaN
mammal   1.669046