Session Ready
Exercise

pandas box plots

While pandas can plot multiple columns of data in a single figure, making plots that share the same x and y axes, there are cases where two columns cannot be plotted together because their units do not match. The .plot() method can generate subplots for each column being plotted. Here, each plot will be scaled independently.

In this exercise your job is to generate box plots for fuel efficiency (mpg) and weight from the automobiles data set. To do this in a single figure, you'll specify subplots=True inside .plot() to generate two separate plots.

All necessary modules have been imported and the automobiles dataset is available in the workspace as df.

Instructions
100 XP
  • Make a list called cols of the column names to be plotted: 'weight' and 'mpg'.
  • Call plot on df[cols] to generate a box plot of the two columns in a single figure. To do this, specify subplots=True.