liveBook · Manning

Standard deviation

As explained in Pandas Workout: 200 exercises to make you a stronger data analyst

A measure of the spread of numerical values around their mean, and a scale parameter of a normal distribution.

Standard deviation measures how widely numerical values spread around their mean. For a normal distribution, it also provides a useful scale: roughly 68% of values fall within one standard deviation of the mean. section 1.15 section 1.5

Use standard deviation to:

  • Summarize spread alongside the mean, median, minimum, quantiles, and maximum. section 1.14 section 1.15
  • Recognize unusually distant values by comparing them with the mean and standard deviation. section 1.9 section 3.23
  • Notice the effect of extreme values: replacing a minimum with five times the maximum changes the mean and standard deviation substantially. section 1.15

Inspecting spread in a Series

Generate 100,000 normally distributed values with mean 0 and standard deviation 100, then call s.describe() to inspect count, mean, standard deviation, quantiles, and extremes. The observed standard deviation is about 100, while the mean and median remain close but not identical because the values are random. section 1.15

import math
math.sqrt(((s - s.mean()) ** 2).sum() / s.count())

Compare the direct pandas calculation with the square-root formula for squared deviations from the mean. section 1.5

How Pandas Workout: 200 exercises to make you a stronger data analyst covers it

How deep it goes
Explains the measure through a formula, normal-distribution interpretation, pandas methods, and an outlier exercise.
Examples
Uses generated normal values, descriptive statistics, altered extrema, test-score bands, city latitudes, and repeated weekly temperatures.
What it assumes
Assumes familiarity with pandas Series, NumPy random generation, indexing, and boolean masks.
What you can do after
Apply it via pandas Series methods to summarize spread, compare observations with thresholds, and investigate outliers.
How it connects
Connects standard deviation with mean, median, normal distribution, quantiles, outliers, and pandas Series.

Also explained in

Compare how 15 books explain standard deviation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pandas Workout: 200 exercises to make you a stronger data analyst. The section links point to the parts of the book it draws on.