0
0
SciPydata~5 mins

Descriptive statistics (describe) in SciPy

Choose your learning style9 modes available
Introduction

Descriptive statistics help us quickly understand the main features of data. They summarize data with simple numbers like mean, variance, and range.

When you want to get a quick summary of a dataset before analysis.
When checking the spread and central tendency of exam scores in a class.
When comparing basic statistics of sales data across different months.
When you want to detect if data has outliers or unusual values.
When preparing data for visualization or further modeling.
Syntax
SciPy
from scipy.stats import describe

result = describe(data, axis=0, ddof=1, bias=False, nan_policy='propagate')

data is your input array or list of numbers.

The describe function returns several statistics like count, mean, variance, skewness, and kurtosis.

Examples
Basic example with a simple list of numbers.
SciPy
from scipy.stats import describe

result = describe([1, 2, 3, 4, 5])
Describes each column separately in a 2D array.
SciPy
import numpy as np
from scipy.stats import describe

data = np.array([[1, 2, 3], [4, 5, 6]])
result = describe(data, axis=0)
Calculate variance with denominator N instead of N-1 by setting ddof=0.
SciPy
from scipy.stats import describe

result = describe([1, 2, 3, 4, 5], ddof=0)
Sample Program

This program calculates and prints basic descriptive statistics for a list of temperatures.

SciPy
from scipy.stats import describe

# Sample data: daily temperatures in Celsius
temperatures = [22, 21, 23, 22, 24, 25, 23, 22, 21, 20]

# Get descriptive statistics
stats = describe(temperatures)

print(f"Count: {stats.nobs}")
print(f"Mean: {stats.mean:.2f}")
print(f"Variance: {stats.variance:.2f}")
print(f"Min: {stats.minmax[0]}")
print(f"Max: {stats.minmax[1]}")
print(f"Skewness: {stats.skewness:.2f}")
print(f"Kurtosis: {stats.kurtosis:.2f}")
OutputSuccess
Important Notes

The describe function ignores NaN values only if nan_policy is set accordingly.

Skewness tells if data is symmetric (0 means symmetric).

Kurtosis indicates if data has heavy or light tails compared to normal distribution.

Summary

Descriptive statistics give a quick summary of data using numbers.

Use scipy.stats.describe to get count, mean, variance, min, max, skewness, and kurtosis.

This helps understand data shape and spread before deeper analysis.