【发布时间】:2017-10-26 19:59:23
【问题描述】:
我有一个 (268X4) df 并找到一列的异常值 (22,1)。我想从 df 中删除那些异常值。我该怎么做?
> df=df_nonull import pandas as pd # to manipulate dataframes import
> numpy as np # to manipulate arrays
>
> # a number "a" from the vector "x" is an outlier if
> # a > median(x)+1.5*iqr(x) or a < median-1.5*iqr(x)
> # iqr: interquantile range = third interquantile - first interquantile def
>outliers(x):
> return np.abs(x- x.median()) > 1.5*(x.quantile(.75)-
>x.quantile(0.25))
>
> # Give the outliers for the first column for example
>outliers=df.StockValue[outliers(df.StockValue)]
【问题讨论】:
标签: python statistics data-science outliers