我如何摆脱熊猫的异常情况?
如果要删除-2σ和2σ之间不存在的值,如何使用IQR删除异常值?
我实现了以下方程式。
iqr = df['abc'].percentile(0.75) - df['abc'].percentile(0.25)
cond1 = (df['abc'] > df['abc'].percentile(0.75) + 2 * iqr)
cond2 = (df['abc'] < df['abc'].percentile(0.25) - 2 * iqr)
df[cond1 & cond2]
这是正确的方式吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是不对的。您的
IQR
几乎永远不等于σ。四分位数和偏差不是相同的事情。幸运的是,您可以使用 series.std() 。
This is not right. Your
iqr
is almost never equal to σ. Quartiles and deviations are not the same things.Fortunately, you can easily compute the standard deviation of a numerical Series using
Series.std()
.