1我正在使用np.where()函数来检索实验特定条件下的精度值。我有一个包含很多列的数据框,包括一个精度框(标题为“correct”)和一个反应时间框(标题为“reactiontime”)。我已使用该函数检索到精确数据;我的代码是:
df['acc1_eyeheight_f'] = np.where((df.metadata == 'eyeheight_f') & (df.frontal_1.str.contains("1")) | (df.frontal_2.str.contains("1")), df.correct, np.NaN) #if metadata had the condition, return the corresponding correct value
acc1_eyeheight_f= df.groupby('participant_private_id').mean()['acc1_eyeheight_f']
print(acc1_eyeheight_f)
但是,当我尝试进行完全相同的操作时,通过以下方式检索反应时间数据:
df['rt1_eyeheight_f'] = np.where((df.metadata == 'eyeheight_f') & (df.frontal_1.str.contains("1")) | (df.frontal_2.str.contains("1")), df.reactiontime, np.NaN) #if metadata had the condition, return the corresponding correct value
rt1_eyeheight_f= df.groupby('participant_private_id').mean()['rt1_eyeheight_f']
print(rt1_eyeheight_f)
我得到一个“rt1\u眼高\u f”的关键错误。当我打印(df)时,列确实存在,并且在错误的位置没有空格
我想知道这是否与单元格内的值有关
提前谢谢-我很困惑
[]
目前没有回答
相关问题 更多 >
编程相关推荐