Assess distribution asymmetry
Exploratory data analysis
SciPy · Function
Computes the sample skewness of a dataset along a chosen axis. It supports bias correction, configurable NaN handling, and optional retention of reduced dimensions.
The function computes the Fisher-Pearson sample skewness from central moments along a selected axis. Set bias to False for bias correction, choose how NaNs are handled with nan_policy, and use keepdims to preserve reduced dimensions.
scipy.stats.skew(a, axis=0, bias=True, nan_policy='propagate', *, keepdims=False)| Name | Type | Description |
|---|---|---|
a | ndarray | Input array. |
axis | int or None, optional | Axis along which skewness is calculated; defaults to 0. If None, compute over the whole array. |
bias | bool, optional | If False, correct the calculations for statistical bias. |
nan_policy | {'propagate', 'raise', 'omit'}, optional | How to handle NaNs: 'propagate' returns NaN, 'raise' throws an error, and 'omit' ignores NaN values. Default: 'propagate'. |
keepdims | bool, optional | Whether reduced axes are retained with size one. |
skewness : ndarray — The skewness of values along an axis, returning NaN where all values are equal.
import numpy as np
from scipy.stats import skew
values = np.array([1, 2, 2, 3, 8])
print(skew(values, bias=False))Computes the bias-corrected skewness of a one-dimensional sample.
Exploratory data analysis
Feature engineering
Data-quality pipelines
Array-based statistics
scipy.stats.skew computes the sample skewness of a dataset. It uses the Fisher-Pearson coefficient, formed from the second and third central moments, and normally returns one value per selected axis slice.
Follow-up: How can the result's shape be retained after reducing an axis? Pass keepdims=True so the reduced axes remain size one.
axis selects the dimension along which the statistic is calculated and defaults to 0. Passing axis=None flattens the input conceptually and computes one result over the whole array.
Follow-up: What happens when axis is None for a multidimensional input? The computation is performed over the entire array rather than independently by a dimension.
nan_policy controls missing values: propagate returns NaN, raise raises an error, and omit ignores NaNs. The default policy is propagate.
Follow-up: Which option should be chosen when missing values must trigger explicit validation? Use nan_policy='raise' so the call fails instead of silently propagating or omitting them.
scipy.stats.skewtestscipy.stats.kurtosisscipy.stats.moment