Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

SciPy · Function

stats.skew

Computes the sample skewness of a dataset along a chosen axis. It supports bias correction, configurable NaN handling, and optional retention of reduced dimensions.

How it works

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.

Syntax

scipy.stats.skew(a, axis=0, bias=True, nan_policy='propagate', *, keepdims=False)

Parameters

NameTypeDescription
andarrayInput array.
axisint or None, optionalAxis along which skewness is calculated; defaults to 0. If None, compute over the whole array.
biasbool, optionalIf False, correct the calculations for statistical bias.
nan_policy{'propagate', 'raise', 'omit'}, optionalHow to handle NaNs: 'propagate' returns NaN, 'raise' throws an error, and 'omit' ignores NaN values. Default: 'propagate'.
keepdimsbool, optionalWhether reduced axes are retained with size one.

Returns

skewness : ndarray — The skewness of values along an axis, returning NaN where all values are equal.

Key points

  • skew measures asymmetry in a sample's distribution.
  • A normal distribution should have skewness close to zero.
  • For a unimodal continuous distribution, a positive value indicates a heavier right tail.
  • Use axis=None to obtain one statistic over the complete input array.
  • With an integer axis, the function returns skewness for values along that axis.
  • Setting bias=False applies the documented statistical-bias correction.
  • nan_policy offers propagation, exception, or omission behavior for NaN-containing inputs.

Common mistakes

  • The default biased estimator is not corrected for statistical bias; pass bias=False when an unbiased correction is wanted.
  • With nan_policy='omit', NaNs are excluded from the calculation, which can leave insufficient data for a meaningful result.
  • Constant slices produce NaN rather than a finite skewness value.

Example: Bias-corrected sample skewness

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.

When to use it

Assess distribution asymmetry

Exploratory data analysis

Measure a numeric feature's tail imbalance

Feature engineering

Detect constant or missing-value slices

Data-quality pipelines

Compute skewness across rows, columns, or the full array

Array-based statistics

Interview questions

QWhat does scipy.stats.skew calculate?

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.

QHow does axis affect the calculation?

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.

QHow are NaN values handled?

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.skewtest
  • scipy.stats.kurtosis
  • scipy.stats.moment

Source: skew — SciPy v1.18.0 Manual. Checked 2026-10-15.