liveBook · Manning

Box-and-whisker plot

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

A boxplot, or box-and-whisker plot, graphically summarizes a numeric distribution using quartiles, a median, whiskers, and possible outliers.

A box-and-whisker plot, or boxplot, summarizes a numeric distribution as a graphical five-number summary. The box runs from the 25% quartile to the 75% quartile, with a line at the median; whiskers extend above and below it. This makes distribution shape and unusual values easier to inspect than a table of descriptive statistics alone. section 11.4 section 11.6

In pandas, create a boxplot with plot.box() on a Series for one numeric variable, or on a DataFrame for numeric columns. Use side-by-side plots to compare related measures or groups, such as minimum versus maximum temperature or values across cities. section 11.4 section 11.5

Use boxplots to answer practical distribution questions:

  • Inspect a variable’s typical range and its quartiles, median, and extremes. section 11.4
  • Find plotted outliers: pandas treats values at least 1.5 × IQR below the 25% quartile or above the 75% quartile as outliers. section 11.6
  • Compare distributions across categories, including cities, months, or states. section 11.5 section 11.18

Compare taxi charges by month

With Seaborn, treat month as the category on the x axis and total_amount as the numeric values on the y axis. sns.catplot(x='month', y='total_amount', data=df, kind='box') produces one boxplot per month, supporting a visual comparison of their distributions alongside grouped mean values. section 11.18

sns.catplot(x='month', y='total_amount', data=df, kind='box')

This concise Seaborn call maps categories to month, values to total_amount, and requests a boxplot. section 11.18

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

How deep it goes
Defines box components and pandas outlier thresholds, then demonstrates pandas and Seaborn plotting without deriving quartile calculations.
Examples
Uses small numeric Series, winter temperatures in three cities, taxi total amounts by month, and earnings by state.
What it assumes
Assumes familiarity with pandas Series, DataFrames, CSV loading, datetime indexes, and basic descriptive statistics.
What you can do after
Apply it via pandas or Seaborn to inspect distributions, identify plotted outliers, and compare numeric values across groups.
How it connects
Connects descriptive statistics, quartiles, median, IQR, outliers, pandas DataFrames, and Seaborn categorical plots.

Also explained in

Compare how 6 books explain box-and-whisker plot →

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.