pandas.core.groupby.DataFrameGroupBy.skew#

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

Return unbiased skew within groups.

Normalized by N-1.

Parameters
axis{0 or ‘index’, 1 or ‘columns’, None}, default 0

Axis for the function to be applied on.

Specifying axis=None will apply the aggregation across both axes.

New in version 2.0.0.

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

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