- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
尝试在 python 中使用 pandas 查找 Excel 工作表的异常值。我能够找到第一个和第三个四分位数,但无法在不返回 NaN
的情况下减去另一个四分位数。
这是基本代码:
absent = pd.read_excel('Absenteeism_at_work.xls')
print("\nOUTLIERS:")
# q1 = (absent.loc[:741, ['Distance from Residence to Work']].quantile([0.25]))
# q3 = (absent.loc[:741, ['Distance from Residence to Work']].quantile([0.75]))
#print(absent.loc[:741, 'Distance from Residence to Work'].quantile([0.25])) #quartile
#print(q1)
# q1, q3 = absent.loc[:741, ['Distance from Residence to Work', 'Transportation expense', 'Month of absence',
# 'Social smoker', 'Social drinker', 'Education']].quantile([0.25 - 0.75])
print(absent.loc[:741, ['Distance from Residence to Work', 'Transportation expense', 'Month of absence',
'Social smoker', 'Social drinker', 'Education']].quantile([0.75])
- absent.loc[:741, ['Distance from Residence to Work', 'Transportation expense', 'Month of absence',
'Social smoker', 'Social drinker', 'Education']].quantile([0.25]))
输出:
OUTLIERS:
Distance from Residence to Work Transportation expense \
0.25 NaN NaN
0.75 NaN NaN
Month of absence Social smoker Social drinker Education
0.25 NaN NaN NaN NaN
0.75 NaN NaN NaN NaN
最佳答案
您的代码只是简单的四分位数范围计算。如果它对你有用,那就太好了。如果您需要真正的异常值检测,这比基于四分位数的模式更复杂,尤其是多变量,您可以求助于 python 包,如 sklearn 或 pyod。
使用分位数函数,您需要清理原始数据以确保它只是数字。特别是,您导入 Excel 文件作为数据源。
检查数据
tmp_df=absent.iloc[:741]
cols = ['居住地到工作地点的距离', '交通费', “缺席的一个月”, “社交吸烟者”, “社交饮酒者”, ‘教育’]
打印(tmp_df[col].quantile(0.25,0.75))
打印(tmp_df[col].describe(include='all'))
祝你好运。
怀俄明州
关于python - 找不到我的数据集的异常值(更具体地说是 IQR),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60291380/
例如,我有一个父类Author: class Author { String name static hasMany = [ fiction: Book,
代码如下: dojo.query(subNav.navClass).forEach(function(node, index, arr){ if(dojo.style(node, 'd
我有一个带有 Id 和姓名的学生表和一个带有 Id 和 friend Id 的 Friends 表。我想加入这两个表并找到学生的 friend 。 例如,Ashley 的 friend 是 Saman
我通过互联网浏览,但仍未找到问题的答案。应该很容易: class Parent { String name Child child } 当我有一个 child 对象时,如何获得它的 paren
我正在尝试创建一个以 Firebase 作为我的后端的社交应用。现在我正面临如何(在哪里?)找到 friend 功能的问题。 我有每个用户的邮件地址。 我可以访问用户的电话也预订。 在传统的后端中,我
我主要想澄清以下几点: 1。有人告诉我,在 iOS 5 及以下版本中,如果您使用 Game Center 设置多人游戏,则“查找 Facebook 好友”(如与好友争夺战)的功能不是内置的,因此您需要
关于redis docker镜像ENTRYPOINT脚本 docker-entrypoint.sh : #!/bin/sh set -e # first arg is `-f` or `--some-
我是一名优秀的程序员,十分优秀!