Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use scipy.stats.skew to calculate sample skewness for an array, either along an axis or across its flattened values. By default, it returns the biased Fisher–Pearson moment coefficient; set bias=False for the adjusted coefficient. The sign describes tail asymmetry, but skewness alone is not a statistical test.

Calculate skewness in Python

Import skew from scipy.stats and pass it a sequence or array:

from scipy.stats import skew

values = [2, 8, 0, 4, 1, 9, 9, 0]
result = skew(values)
print(result)  # 0.2650554122698573

This matches an example in the SciPy v1.18.0 skew reference. That page also shows that skew([1, 2, 3, 4, 5]) returns 0.0.

What SciPy’s skewness value means

SciPy defines the default coefficient as g₁ = m₃ / m₂3/2, where m₂ and m₃ are the second and third central moments calculated using denominator N. For a unimodal continuous distribution, a positive value indicates greater weight in the right tail; a value below zero indicates greater weight in the left tail. A normally distributed sample should have skewness about zero, though a finite sample need not produce exactly zero.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall

Skewness is a descriptive measure, not a test of whether the distribution is statistically skewed. SciPy’s skew reference points to scipy.stats.skewtest for assessing statistically whether skewness is close enough to zero. The SciPy v1.18.0 statistical functions index also lists related distribution checks such as normaltest and jarque_bera.

Choose biased or adjusted skewness

The default bias=True returns the moment coefficient g₁. To apply SciPy’s bias adjustment, use bias=False; the adjusted Fisher–Pearson coefficient is G₁ = √(N(N−1))/(N−2) × m₃/m₂3/2.

Rank #2
Sale
Statistics Laminate Reference Chart: Parameters, Variables, Intervals, Proportions (Quickstudy: Academic )
  • This guide is a perfect overview for the topics covered in introductory statistics courses.
from scipy.stats import skew

biased = skew(values)                 # bias=True by default
adjusted = skew(values, bias=False)

The choice changes the estimator, not the direction convention: positive still means greater right-tail weight under SciPy’s stated interpretation. Use the same setting when comparing results across datasets or analyses. SciPy’s describe reference likewise documents that skewness and kurtosis calculations can be bias-corrected.

Control axes, NaNs, and output shape

For a multidimensional array, axis=0 is the default, so SciPy calculates skewness along axis 0. Use another axis to select a different direction, or set axis=None to flatten the input before calculating one value. keepdims=True leaves reduced axes in the result as dimensions of length one, which can help with broadcasting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Option Behavior Example
axis=0 Calculate along axis 0 (default). skew(data, axis=0)
axis=1 or another axis Calculate along the selected axis. skew(data, axis=1)
axis=None Flatten the input and calculate a single result. skew(data, axis=None)
nan_policy='propagate' Default: an affected axis slice returns NaN. skew(data, nan_policy='propagate')
nan_policy='omit' Ignore NaNs; a slice with too few usable values returns NaN. skew(data, nan_policy='omit')
nan_policy='raise' Raise ValueError if NaNs are present. skew(data, nan_policy='raise')
keepdims=True Retain reduced axes as dimensions of length one. skew(data, axis=1, keepdims=True)

These options are documented in the SciPy v1.18.0 function reference. Select the NaN policy to match your workflow rather than assuming missing values are removed automatically.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Degenerate data and compatibility

If all values in a slice are equal, SciPy’s current reference says the result is NaN. This is a zero-variation case, so do not treat the NaN as a measured skew direction.

The SciPy v1.18.0 reference labels its Array API support experimental. It lists NumPy on CPU, CuPy on GPU, PyTorch on CPU and GPU, JAX on CPU and GPU, and Dask on CPU. These are the combinations listed for that version; compatibility may differ in other SciPy versions or environments. See the versioned compatibility table before relying on a particular backend.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.