Skip to content

Commit bf5a388

Browse files
committed
BUG: remove index and sort onset
1 parent 4524eb9 commit bf5a388

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import pandas as pd
22
from os.path import join
3+
from pathlib import Path
34
# load csv file
45
file_dir = '/Users/h/Documents/projects_local/1076_spacetop'
56
flist = [
67
'sub-0001/ses-04/func/sub-0001_ses-04_task-fractional_acq-mb8_run-01_events.tsv',
78
'sub-0001/ses-04/func/sub-0001_ses-04_task-fractional_acq-mb8_run-02_events.tsv'
89
]
910
for fname in flist:
10-
df = pd.read_csv(join(file_dir, fname), sep='\t')
11-
newdf = df.sort_values(by=['onset'])
12-
newdf.to_csv(join(file_dir, fname), sep='\t')
11+
if Path(join(file_dir, fname)).exists():
12+
df = pd.read_csv(join(file_dir, fname), sep='\t')
13+
newdf = df.sort_values(by=['onset'])
14+
newdf_na = newdf.fillna('n/a')
15+
newdf_na.to_csv(join(file_dir, fname), sep='\t', index=False)

0 commit comments

Comments
 (0)