text_html_output_1.png text_plain_output_1.png
import ast

import pandas as pd

stimulus=pd.read_excel("/kaggle/input/young-adults-affective-data-ecg-and-gsr-signals/ECG_GSR_Emotions/Stimulus_Description.xlsx")
stimulus["Target Emotion"]=stimulus["Target Emotion"].str.title()
stimulus.info()
stimulus.head()

gsr_data = pd.read_excel('/kaggle/input/young-adults-affective-data-ecg-and-gsr-signals/ECG_GSR_Emotions/Self-Annotation Labels/Self-annotation Multimodal_Use.xlsx')
gsr_data['filename'] = 'GSRdata_s' + gsr_data['Session ID'].astype(str) + 'p' + gsr_data['Participant Id'].astype(str) + 'v' + gsr_data['Video ID'].astype(str) + '.dat'
PATH_2 = '/kaggle/input/young-adults-affective-data-ecg-and-gsr-signals/ECG_GSR_Emotions/Raw Data/Multimodal/GSR/'
gsr_data['filename'] = gsr_data['filename'].str.replace('GSRdata_s2p9v3.dat', 'GSRdata_S2p9v3.dat', regex=False)
gsr_data['GSR_list'] = gsr_data['filename'].apply(lambda x: list(pd.read_table(PATH_2 + x).iloc[:, 0]))
gsr_data = gsr_data.merge(stimulus.iloc[:, 0:3], on=['Session ID', 'Video ID'])
gsr_data.to_csv('gsr_data.csv', index=False)

gsr_data = pd.read_csv('/kaggle/working/gsr_data.csv')

gsr_proc = gsr_data[['Emotion', 'GSR_list']].copy()
gsr_proc['GSR_list'] = gsr_proc['GSR_list'].apply(lambda x: ast.literal_eval(x))
gsr_proc = pd.concat([gsr_proc, pd.DataFrame(gsr_proc['GSR_list'].tolist())], axis=1).drop(columns=['GSR_list'])
for i in range(gsr_proc.shape[1] - 1):
    gsr_proc[i] = pd.to_numeric(gsr_proc[i])
gsr_proc.to_csv('gsr_proc.csv', index=False)

gsr_proc = pd.read_csv('/kaggle/working/gsr_proc.csv')
gsr_proc.info()
gsr_proc.head()