Descriptive Statistics in Python
Calculate mean, median, mode, variance, standard deviation and percentiles
Descriptive statistics summarise a dataset's main characteristics. They are the foundation of any analysis — before you build charts or draw conclusions, you need to understand the central tendency (what is typical) and dispersion (how spread out) of your data.
Python with NumPy and Pandas provides all standard descriptive statistics with clean, readable code.
Example
Key Points
- ✓Mean is sensitive to outliers — use median for skewed data (like income or sales)
- ✓Standard deviation tells you the typical distance from the mean
- ✓Coefficient of variation (std/mean × 100) compares spread across different-scale metrics
- ✓Positive skew: mean > median (few very high values pull the mean up)
- ✓describe() with percentiles=[0.1, 0.9] shows 10th and 90th percentiles instead of default
Practice Question
A salary dataset has a few extremely high executive salaries. Which measure of central tendency better represents the "typical" salary?
Related Topics
Outlier Detection in PythonIdentify and handle outliers using IQR, z-score and visualisation methodsCorrelation AnalysisFind relationships between variables using Pearson correlation and Seaborn heatmapsgroupby and Pivot TablesAggregate data by category with groupby — the Pandas equivalent of Excel pivot tables