python删除同名列_如何从具有多个同名列的数据帧行中删除离群值?

您可以使用内四分位范围(IQR)进行简单的异常值检测。来自维基百科The interquartile range (IQR), also called the midspread or middle 50%, or technically H-spread, is a measure of statistical dispersion, being equal to the difference between 75th and 25th percentiles, or between upper and lower quartiles, IQR = Q3 − Q1.

In other words, the IQR is the first quartile subtracted from the third quartile; these quartiles can be clearly seen on a box plot on the data.

It is a measure of the dispersion similar to standard deviation or variance, but is much more robust against outliers.Q1 = data.quantile(0.25)

Q3 = data.quantile(0.75)

IQR = Q3 - Q1

print(IQR)

if(data[i] < (Q1 - 1.5 * IQR)) |(data[i] > (Q3 + 1.5 * IQR))

#outlier detected

#do stuff ...

如果数据点位于异常值边界之外,则该数据点可能是异常值。因此,在您的情况下,基于逻辑,您计算每列或所有列的异常值,这取决于您拥有的数据以及它们之间的关系。希望有帮助。在

顺便说一句,您可以使用matplotlib boxplot将上述方法可视化。只要把你正在做异常值检测的一系列数据传递给你,它会直接为你做并绘制出来。

还有其他方法,比如scikit learnoutlier detection

这个blog也很有用。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值