liveBook · Manning

Median

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

The median is the middle value of an ordered set of numerical values, with averaging of the two middle values when the set has even size.

The median is the middle value of an ordered set. Sort the values first; with an even number of values, average the two innermost values. Unlike the mean, the median changes relatively little when one unusually large or small value is introduced. section 1.5

In pandas, Series.median() returns the median, while Series.quantile(0.5) expresses the same measurement. The describe() method includes it as the 50% entry alongside the mean, quartiles, minimum, and maximum. section 1.15

Compare center and spread

Generate 100,000 normally distributed values with mean 0 and standard deviation 100, then inspect s.describe(). The displayed mean is 0.157670 and the median, or 50% quantile, is 0.172022, so they are close. Replacing every minimum value with five times the maximum raises the maximum dramatically, while the median changes only slightly; the mean and standard deviation respond more noticeably.

Use the median when a central value should represent a population without being dominated by extreme observations. Compare it with the mean and standard deviation: closeness between mean and median can suggest a balanced distribution, while a gap can signal asymmetry or influential values. section 1.5 section 1.9

Practical exercises include comparing taxi passenger quantiles, measuring city growth with mean and median changes, and considering how unusual observations affect descriptive statistics. section 1.25 section 3.23

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

How deep it goes
Explains ordering, even-sized sets, quantile equivalence, and outlier behavior, but stops short of implementation internals.
Examples
Uses normally distributed Series, modified minima, taxi passenger quantiles, and city-growth comparisons.
What it assumes
Assumes familiarity with pandas Series and descriptive statistics while teaching the median from its ordered-value definition.
What you can do after
Apply it via pandas Series.median() or quantile(0.5), then compare the result with the mean when outliers matter.
How it connects
Connects the median with mean, quantiles, descriptive statistics, standard deviation, distributions, and outliers.

Also explained in

Compare how 7 books explain median →

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.