-
Notifications
You must be signed in to change notification settings - Fork 2
/
reject_subs.py
37 lines (27 loc) · 1.01 KB
/
reject_subs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
import os
import pandas as pd
data = pd.read_csv("/data/chs_data.csv")
os.chdir("/data/")
data = data[data['Reaction Time'] > 0]
data = data.dropna(axis=0, subset=['Response'])
data = data[data['display'] == 'chs']
subs = data['Participant Private ID'].unique()
check = data[data['dimension'] == 'checkup']
rejected_subs = []
for s in range(len(pd.unique(subs))):
reject = []
sub = check[check['Participant Private ID'] == subs[s]]
for q in sub.qnum.unique():
if sub[sub.qnum==q]['qdirection'].values[0] == 'reversed':
if sub[sub.qnum==q]['Response'].values[0] > 1:
reject.append('reject')
if sub[sub.qnum==q]['qdirection'].values[0] == 'forward':
if sub[sub.qnum==q]['Response'].values[0] < 4:
reject.append('reject')
print(reject)
if len(reject) > 2:
rejected_subs.append(subs[s])
for r in rejected_subs:
re = check[check['Participant Private ID']==r]
re.to_csv('reject'+str(r)+'.csv')