-
Notifications
You must be signed in to change notification settings - Fork 0
/
preprocessor.py
43 lines (33 loc) · 935 Bytes
/
preprocessor.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
38
39
40
41
42
43
import os
import numpy as np
import pandas as pd
filenames = []
for file in os.listdir("records"):
filenames.append(file)
def drop_nan(data):
before = data.shape[0]
data = data.dropna(axis=0)
after = data.shape[0]
return before, after
for filename in filenames:
# read the csv file
data = pd.read_csv("records/" + filename, header=None)
before, after = drop_nan(data)
if before != after:
print(f"File {filename} has {before - after} rows with nan.")
# # time should be increasing, sort by time
# data = data.sort_values(by=[0])
# # time is the 1st column
# time = np.array(data.iloc[:, 0])
#
# # eeg is the 2 - 7 columns
# eeg = np.array(data.iloc[:, 1:7])
#
# # confirmed is the 8th column
# confirmed = np.array(data.iloc[:, 7])
#
# # consecutive is the 9th column
# consecutive = np.array(data.iloc[:, 8])
#
# # grid is the 10 - 18 columns
# grid = np.array(data.iloc[:, 9:17])