Learn
Boxplots
Interquartile Range

Now that we’ve drawn the median, let’s draw the edges of the box. The box extends to the first and third quartile of the dataset.

This visually splits the data into fourths. One-quarter of the data will fall outside of the box to the left. Another quarter of the data will fall between the left side of the box and the median line. A third quarter of the data falls between the median line and the right side of the box. And the last quarter of the data falls outside the box to the right.

By drawing the edges of the box using the first and third quartiles, the interquartile range is visualized. The length of the box represents this commonly used descriptive statistic.

We can use NumPy’s quantile() function to find the first and third quartile:

dataset = [4, 8, 15, 16, 23] first_quartile = np.quantile(dataset, 0.25) third_quartile = np.quantile(dataset, 0.75)

Instructions

1.

Create a variable named quartile_one. Use NumPy’s np.quantile() function to find dataset‘s first quartile.

2.

Create a variable named quartile_three. Use NumPy’s np.quantile() function to find dataset‘s third quartile.

3.

Look at the two values printed out. Use those values to draw the edges of the box in the browser component.

Once again, when you’re ready to move on, run your code again and click the “Next” button.

Folder Icon

Sign up to start coding

Already have an account?