Learn

Interquartile Range

IQR in SciPy

In the last exercise, we calculated the IQR by finding the quartiles using NumPy and finding the difference ourselves. The SciPy library has a function that can calculate the IQR all in one step.

The `iqr()`

function takes a dataset as a parameter and returns the Interquartile Range. Notice that when we imported `iqr()`

, we imported it from the `stats`

submodule:

From scipy.stats import iqr dataset = [4, 10, 38, 85, 193] interquartile_range = iqr(dataset)

### Instructions

**1.**

Let’s calculate the IQR again, but this time, use SciPy’s function.

Create a variable named `interquartile_range`

and set it equal to the result of calling `iqr()`

using `songs`

as a parameter.