我需要识别数据帧中的异常值,在我的情况下,这些值高于4*Z-score。“我的数据帧”有许多按日期排序的列(2012-01-01 1:30:00)。你知道吗
这些值遵循时间模式和温度数据,因此我们需要同时评估给定数据与其他数据相比是否存在差异。例如,如果我将下午记录与其他时段的值进行比较,这可能被认为是错误的差异。你知道吗
我试了一些东西只为一个专栏,但没有结果。你知道吗
hours = ['00:00','01:00','02:00','03:00','04:00','05:00','06:00','07:00','08:00','09:00','10:00','11:00','12:00','13:00','14:00','15:00','16:00','17:00','18:00','19:00','20:00','21:00','22:00','23:00','23:59']
df = pd.read_excel(file)
df.set_index('Date',inplace=True)
for i in range(24):
df.loc[df[np.abs((df['column1'].between_time(hours[i],hours[i+1]) - df['column1'].between_time(hours[i],hours[i+1]).mean())/df['column1'].between_time(hours[i],hours[i+1]).std()) > 4], 'column1']='outlier'
目前没有回答
相关问题 更多 >
编程相关推荐