Winsorizing data
Winsorizing is another technique to deal with outliers and is named after Charles Winsor. In effect, Winsorization clips outliers to given percentiles in a symmetric fashion. For instance, we can clip to the 5th and 95th percentile. SciPy has a winsorize()
function, which performs this procedure. The data for this recipe is the same as that for the Clipping and filtering outliers recipe.
How to do it...
Winsorize the data with the following procedure:
- The imports are as follows:
rom scipy.stats.mstats import winsorize import statsmodels.api as sm import seaborn as sns import matplotlib.pyplot as plt import dautil as dl from IPython.display import HTML
- Load and winsorize the data for the effective temperature (limit is set to 15%): ...
Get Python Data Analysis Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.