O'Reilly logo

NumPy Cookbook - Second Edition by Ivan Idris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Studying extreme values of atmospheric pressure

Outliers are a problem because they influence our understanding of data. In this recipe, we define outliers to be away from the first or third quartile of the data by at least 1.5 times the interquartile range. The interquartile range is the distance between the first and third quartiles. Let's count the outliers for each month of the year. The complete code is in the extreme.py file in this book's code bundle:

import numpy as np import matplotlib.pyplot as plt import calendar as cal data = np.load('cbk12.npy') # Multiply to get hPa values meanp = .1 * data[:,1] # Filter out 0 values meanp = np.ma.array(meanp, mask = meanp == 0) # Calculate quartiles and irq q1 = np.percentile(meanp, 25) median = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required