import pandas as pd

#neutral = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\eryao\neutral_eryao.csv") #Label = 0
#wipers = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\eryao\wipers_eryao.csv") #Label = 1
#number7 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\eryao\num7_eryao.csv") #label = 2
#chicken = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\eryao\chicken_eryao.csv") #label = 3
#sidestep = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\eryao\sidestep_eryao.csv") #Label = 4
#turnclap = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\eryao\turnclap_eryao.csv") #Label = 5
#number6 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\eryao\num6_eryao.csv") #label = 6
#salute = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\eryao\salute_eryao.csv") #label = 7
#mermaid = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\eryao\mermaid_eryao.csv") #label = 8
#swing = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\eryao\swing_eryao.csv") #label = 9
#cowboy = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\eryao\cowboy_eryao.csv") #label = 10
#bow = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\eryao\bow_eryao.csv") #label = 11

#neutral = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\yp\neutral_yp.csv") #Label = 0
#wipers = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\yp\wipers_yp.csv") #Label = 1
#number7 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\yp\num7_yp.csv") #label = 2
#chicken = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\yp\chicken_yp.csv") #label = 3
#sidestep = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\yp\sidestep_yp.csv") #Label = 4
#turnclap = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\yp\turnclap_yp.csv") #Label = 5
#number6 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\yp\num6_yp.csv") #label = 6
#salute = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\yp\salute_yp.csv") #label = 7
#mermaid = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\yp\mermaid_yp.csv") #label = 8
#swing = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\yp\swing_yp.csv") #label = 9
#cowboy = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\yp\cowboy_yp.csv") #label = 10
#bow = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\yp\bow_yp.csv") #label = 11

#neutral = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\fuad\neutral_fuad.csv") #Label = 0
#wipers = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\fuad\wipers_fuad.csv") #Label = 1
#number7 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\fuad\num7_fuad.csv") #label = 2
#chicken = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\fuad\chicken_fuad.csv") #label = 3
#sidestep = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\fuad\sidestep_fuad.csv") #Label = 4
#turnclap = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\fuad\turnclap_fuad.csv") #Label = 5
#number6 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\fuad\num6_fuad.csv") #label = 6
#salute = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\fuad\salute_fuad.csv") #label = 7
#mermaid = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\fuad\mermaid_fuad.csv") #label = 8
#swing = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\fuad\swing_fuad.csv") #label = 9
#cowboy = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\fuad\cowboy_fuad.csv") #label = 10
#bow = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\fuad\bow_fuad.csv") #label = 11

neutral = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\neutral_melvin.csv") #Label = 0
wipers = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\wipers_melvin.csv") #Label = 1
number7 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\num7_melvin.csv") #label = 2
chicken = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\chicken_melvin.csv") #label = 3
sidestep = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\sidestep_melvin.csv") #Label = 4
turnclap = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\turnclap_melvin.csv") #Label = 5
number6 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\num6_melvin.csv") #label = 6
salute = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\salute_melvin.csv") #label = 7
mermaid = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\mermaid_melvin.csv") #label = 8
swing = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\swing_melvin.csv") #label = 9
cowboy = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\cowboy_melvin.csv") #label = 10
cowboy2 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\cowboy_melvin_2.csv") #label = 10
sidestep2 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\sidestep_melvin_2.csv") #Label = 4
turnclap2 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\turnclap_melvin_2.csv") #Label = 5
bow = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\melvin\bow_melvin.csv") #label = 11

#neutral = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\ben\neutral_ben.csv") #Label = 0
#wipers = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\ben\wipers_ben.csv") #Label = 1
#number7 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\ben\num7_ben.csv") #label = 2
#chicken = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\ben\chicken_ben.csv") #label = 3
#sidestep = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\ben\sidestep_ben.csv") #Label = 4
#turnclap = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\ben\turnclap_ben.csv") #Label = 5
#number6 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\ben\num6_ben.csv") #label = 6
#salute = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\ben\salute_ben.csv") #label = 7
#mermaid = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\ben\mermaid_ben.csv") #label = 8
#swing = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\ben\swing_ben.csv") #label = 9
#cowboy = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\ben\cowboy_ben.csv") #label = 10
#bow = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\ben\bow_ben.csv") #label = 11

#neutral = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\xh\neutral_xh.csv") #Label = 0
#wipers = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\xh\wipers_xh.csv") #Label = 1
#number7 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\xh\num7_xh.csv") #label = 2
#chicken = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\xh\chicken_xh.csv") #label = 3
#sidestep = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\xh\sidestep_xh.csv") #Label = 4
#turnclap = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\xh\turnclap_xh.csv") #Label = 5
#number6 = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\xh\num6_xh.csv") #label = 6
#salute = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\xh\salute_xh.csv") #label = 7
#mermaid = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\xh\mermaid_xh.csv") #label = 8
#swing = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\xh\swing_xh.csv") #label = 9
#cowboy = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\xh\cowboy_xh.csv") #label = 10
#bow = pd.read_csv(r"C:\Users\user\Desktop\CG3002 dataset\xh\bow_xh.csv") #label = 11

labels = []
feature = []
numOfData = 110
overlapNum = 11
numRowsOfchicken = chicken.shape[0]
numRowsOfwipers = wipers.shape[0]
numRowsOfnumber7 = number7.shape[0]
numRowsOfturnclap = turnclap.shape[0]
numRowsOfsidestep = sidestep.shape[0]
numRowsOfnumber6 = number6.shape[0]
numRowsOfsalute = salute.shape[0]
numRowsOfmermaid = mermaid.shape[0]
numRowsOfswing = swing.shape[0]
numRowsOfcowboy = cowboy.shape[0]
numRowsOfbow = bow.shape[0]
numRowsOfneutral = neutral.shape[0]
numRowsOfturnclap2 = turnclap2.shape[0]
numRowsOfsidestep2 = sidestep2.shape[0]
numRowsOfcowboy2 = cowboy2.shape[0]
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

i=0

for line in chicken.iterrows():
    a = chicken[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfchicken - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
chicken_extracted_data = mean_data.join(max_data)
chicken_extracted_data = chicken_extracted_data.join(iqr_data)
chicken_extracted_data['activity'] = activity
#chicken_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\chicken_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in neutral.iterrows():
    a = neutral[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfneutral - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
neutral_extracted_data = mean_data.join(max_data)
neutral_extracted_data = neutral_extracted_data.join(iqr_data)
neutral_extracted_data['activity'] = activity
#neutral_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\neutral_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in wipers.iterrows():
    a = wipers[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfwipers - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
wipers_extracted_data = mean_data.join(max_data)
wipers_extracted_data = wipers_extracted_data.join(iqr_data)
wipers_extracted_data['activity'] = activity
#wipers_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\wipers_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in number7.iterrows():
    a = number7[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfnumber7 - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
number7_extracted_data = mean_data.join(max_data)
number7_extracted_data = number7_extracted_data.join(iqr_data)
number7_extracted_data['activity'] = activity
#number7_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\number7_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in sidestep.iterrows():
    a = sidestep[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfsidestep - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
sidestep_extracted_data = mean_data.join(max_data)
sidestep_extracted_data = sidestep_extracted_data.join(iqr_data)
sidestep_extracted_data['activity'] = activity
#sidestep_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\sidestep_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in turnclap.iterrows():
    a = turnclap[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfturnclap - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
turnclap_extracted_data = mean_data.join(max_data)
turnclap_extracted_data = turnclap_extracted_data.join(iqr_data)
turnclap_extracted_data['activity'] = activity
#turnclap_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\turnclap_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in number6.iterrows():
    a = number6[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfnumber6 - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
number6_extracted_data = mean_data.join(max_data)
number6_extracted_data = number6_extracted_data.join(iqr_data)
number6_extracted_data['activity'] = activity
#number6_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\number6_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in salute.iterrows():
    a = salute[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfsalute - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
salute_extracted_data = mean_data.join(max_data)
salute_extracted_data = salute_extracted_data.join(iqr_data)
salute_extracted_data['activity'] = activity
#salute_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\salute_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in mermaid.iterrows():
    a = mermaid[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfmermaid - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
mermaid_extracted_data = mean_data.join(max_data)
mermaid_extracted_data = mermaid_extracted_data.join(iqr_data)
mermaid_extracted_data['activity'] = activity
#mermaid_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\mermaid_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in swing.iterrows():
    a = swing[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfswing - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
swing_extracted_data = mean_data.join(max_data)
swing_extracted_data = swing_extracted_data.join(iqr_data)
swing_extracted_data['activity'] = activity
#swing_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\swing_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in cowboy.iterrows():
    a = cowboy[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfcowboy - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
cowboy_extracted_data = mean_data.join(max_data)
cowboy_extracted_data = cowboy_extracted_data.join(iqr_data)
cowboy_extracted_data['activity'] = activity
#cowboy_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\cowboy_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in bow.iterrows():
    a = bow[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfbow - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
bow_extracted_data = mean_data.join(max_data)
bow_extracted_data = bow_extracted_data.join(iqr_data)
bow_extracted_data['activity'] = activity
#bow_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\bow_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in sidestep2.iterrows():
    a = sidestep2[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfsidestep2 - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
sidestep2_extracted_data = mean_data.join(max_data)
sidestep2_extracted_data = sidestep2_extracted_data.join(iqr_data)
sidestep2_extracted_data['activity'] = activity
#sidestep2_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\sidestep2_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in turnclap2.iterrows():
    a = turnclap2[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfturnclap2 - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
turnclap2_extracted_data = mean_data.join(max_data)
turnclap2_extracted_data = turnclap2_extracted_data.join(iqr_data)
turnclap2_extracted_data['activity'] = activity
#turnclap2_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\turnclap2_extracted_dataset.csv',index=False)

i=0
mean_data = pd.DataFrame()
max_data = pd.DataFrame()
iqr_data = pd.DataFrame()

for line in cowboy2.iterrows():
    a = cowboy2[i:i+numOfData:].copy()
    a.loc['mean'] = a.mean()
    a.loc['max'] = a.max()
    Q3 = a.quantile(0.75)
    Q1 = a.quantile(0.25)
    a.loc['iqr'] = Q3 - Q1
    mean_data = mean_data.append(a.loc['mean'], ignore_index = True)
    max_data = max_data.append(a.loc['max'], ignore_index = True)
    iqr_data = iqr_data.append(a.loc['iqr'], ignore_index = True)
    
    if( (i + overlapNum) > (numRowsOfcowboy2 - numOfData)):
        break
    else:
        i = i + overlapNum

mean_data = mean_data.rename(index=str, columns={'GyX 1': 'mean_GyX 1', 'GyY 1': 'mean_GyY 1', 'GyZ 1': 'mean_GyZ 1',
                                                 'AcX 1': 'mean_AcX 1', 'AcY 1': 'mean_AcY 1', 'AcZ 1': 'mean_AcZ 1',
                                                 'GyX 2': 'mean_GyX 2', 'GyY 2': 'mean_GyY 2', 'GyZ 2': 'mean_GyZ 2',
                                                 'AcX 2': 'mean_AcX 2', 'AcY 2': 'mean_AcY 2', 'AcZ 2': 'mean_AcZ 2', })
max_data = max_data.rename(index=str, columns=  {'AcX 1': 'max_AcX 1', 'AcY 1': 'max_AcY 1', 'AcZ 1': 'max_AcZ 1', 
                                                 'GyX 1': 'max_GyX 1', 'GyY 1': 'max_GyY 1', 'GyZ 1': 'max_GyZ 1',
                                                 'AcX 2': 'max_AcX 2', 'AcY 2': 'max_AcY 2', 'AcZ 2': 'max_AcZ 2', 
                                                 'GyX 2': 'max_GyX 2', 'GyY 2': 'max_GyY 2', 'GyZ 2': 'max_GyZ 2',})
iqr_data = iqr_data.rename(index=str, columns=  {'AcX 1': 'iqr_AcX 1', 'AcY 1': 'iqr_AcY 1', 'AcZ 1': 'iqr_AcZ 1', 
                                                 'GyX 1': 'iqr_GyX 1', 'GyY 1': 'iqr_GyY 1', 'GyZ 1': 'iqr_GyZ 1',
                                                 'AcX 2': 'iqr_AcX 2', 'AcY 2': 'iqr_AcY 2', 'AcZ 2': 'iqr_AcZ 2', 
                                                 'GyX 2': 'iqr_GyX 2', 'GyY 2': 'iqr_GyY 2', 'GyZ 2': 'iqr_GyZ 2',})

activity = mean_data['activity'].copy()
mean_data = mean_data.drop(['activity'], axis = 1)
max_data = max_data.drop(['activity'], axis = 1)
iqr_data = iqr_data.drop(['activity'], axis = 1)
cowboy2_extracted_data = mean_data.join(max_data)
cowboy2_extracted_data = cowboy2_extracted_data.join(iqr_data)
cowboy2_extracted_data['activity'] = activity
#cowboy2_extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\cowboy2_extracted_dataset.csv',index=False)

frames = [neutral_extracted_data, wipers_extracted_data, number7_extracted_data, chicken_extracted_data, sidestep_extracted_data, turnclap_extracted_data, 
          number6_extracted_data, salute_extracted_data, mermaid_extracted_data, swing_extracted_data, cowboy_extracted_data, bow_extracted_data,
          sidestep2_extracted_data, turnclap2_extracted_data, cowboy2_extracted_data]
extracted_data = pd.concat(frames)
#extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\eryao_extracted_dataset.csv',index=False)
#extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\yupeng_extracted_dataset.csv',index=False)
#extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\fuad_extracted_dataset.csv',index=False)
extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\melvin_extracted_dataset.csv',index=False)
#extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\ben_extracted_dataset.csv',index=False)
#extracted_data.to_csv(r'C:\Users\User\Desktop\CG3002 extracted features\xinhui_extracted_dataset.csv',index=False)

