我想从异常值中清除数据集,但只在三个特定列中,因为其他10个列包含分类变量。那么,如何通过只引用这些特定列来清理数据呢?在
我想用像质计测距法。这就是我目前运行的代码:
import numpy as np
def outliers(x):
return np.abs(x- x.median()) > 1.5*(x.quantile(.75)-x.quantile(0.25))
ath2.Age[outliers(ath2.Age)]
ath2.Height[outliers(ath2.Height)]
ath2.Weight[outliers(ath2.Weight)]
在检查了我感兴趣的列中的异常值的数量之后,我不知道如何继续下去。在
如果您希望代码是动态的,您可以首先通过下面的代码检查不属于类别的列:
或者,也可以根据您的数据帧使用}参数
include
或{在此运行之后,下面的代码来自上面的列:
^{pr2}$或
如果您只想用数字列创建一个新的df,并一次性找出异常值,代码如下:
相关问题 更多 >
编程相关推荐