text_html_output_1.png
import glob

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

data_directory = '/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/'

defog_meta = pd.read_csv(data_directory + 'defog_metadata.csv')
tdcsfog_meta = pd.read_csv(data_directory + 'tdcsfog_metadata.csv')

def prepare_fog_table(df_type):
    full_data = pd.DataFrame()
    subdatas = glob.glob(data_directory + f'train/{df_type}/*')
    for subdata in subdatas:
        sub_data = pd.read_csv(subdata)
        sub_data['id'] = subdata.split(sep='/')[-1].split(sep='.')[0]
        if df_type == 'defog':
            sub_data['visit'] = defog_meta.loc[defog_meta['Id'] == subdata.split(sep='/')[-1].split(sep='.')[0], 'Visit'].to_list()[0]
            sub_data['medication'] = defog_meta.loc[defog_meta['Id'] == subdata.split(sep='/')[-1].split(sep='.')[0], 'Medication'].to_list()[0]
            sub_data['subject'] = defog_meta.loc[defog_meta['Id'] == subdata.split(sep='/')[-1].split(sep='.')[0], 'Subject'].to_list()[0]
            sub_data['test'] = 0
            sub_data['type'] = df_type
            full_data = pd.concat([full_data, sub_data]).reset_index(drop=True)
        else:
            sub_data['visit'] = tdcsfog_meta.loc[tdcsfog_meta['Id'] == subdata.split(sep='/')[-1].split(sep='.')[0], 'Visit'].to_list()[0]
            sub_data['medication'] = tdcsfog_meta.loc[tdcsfog_meta['Id'] == subdata.split(sep='/')[-1].split(sep='.')[0], 'Medication'].to_list()[0]
            sub_data['subject'] = tdcsfog_meta.loc[tdcsfog_meta['Id'] == subdata.split(sep='/')[-1].split(sep='.')[0], 'Subject'].to_list()[0]
            sub_data['test'] = tdcsfog_meta.loc[tdcsfog_meta['Id'] == subdata.split(sep='/')[-1].split(sep='.')[0], 'Test'].to_list()[0]
            sub_data['type'] = df_type
            full_data = pd.concat([full_data, sub_data]).reset_index(drop=True)
    return full_data

defog_full_table = prepare_fog_table('defog')
defog_full_table