<filename>data_preprocessing.py
# -*- coding: utf-8 -*-
"""Data Preprocessing.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1W5Ipe_XX0MZrlF83ytB_TRNqQZl0GDA_
"""

import pandas as pd
import numpy as np
Average = np.zeros([39,8])
sd = np.zeros([39,8])
V70arr = np.zeros(39)
V60 = 0
for i in range(1,40):
  if i < 10 :
    data = pd.read_csv("live0"+ str(i) +".csv")
  else:
    data = pd.read_csv("live"+ str(i) +".csv")
  if i<5 or i>12:
    data = data.shift(1,axis = 1)
  data = data.drop(columns = ['ENGINE_RUN_TINE ()','COMMANDED_EVAPORATIVE_PURGE ()', 'TIME_RUN_WITH_MIL_ON ()','TIME_SINCE_TROUBLE_CODES_CLEARED ()',
       'DISTANCE_TRAVELED_WITH_MIL_ON ()', 'WARM_UPS_SINCE_CODES_CLEARED ()','FUEL_TANK ()', 'ABSOLUTE_THROTTLE_B ()', 'PEDAL_D ()', 'PEDAL_E ()',
       'COMMANDED_THROTTLE_ACTUATOR ()', 'FUEL_AIR_COMMANDED_EQUIV_RATIO ()',
       'ABSOLUTE_BAROMETRIC_PRESSURE ()', 'RELATIVE_THROTTLE_POSITION ()',
       'INTAKE_AIR_TEMP ()', 'TIMING_ADVANCE ()',
       'CATALYST_TEMPERATURE_BANK1_SENSOR1 ()',
       'CATALYST_TEMPERATURE_BANK1_SENSOR2 ()', 'CONTROL_MODULE_VOLTAGE ()'])
  for j in range(len(data.columns)):
    Average[i-1][j] = pd.DataFrame.mean(data[data.columns[j]])
    sd[i-1][j] = pd.DataFrame.std(data[data.columns[j]])
    if data.columns[j]== 'VEHICLE_SPEED ()':
      data = data.reset_index(drop=True)
      speed = np.array(data['VEHICLE_SPEED ()'])
      if i==4:
        m = speed
      l= 0
      for k in range(len(speed)):
        if speed[k]> 70:
          l= l+1
         # if i==5:
          #  print(k)
      V60 = (l/len(speed))*100
  V70arr[i-1] = V60
<filename>data_preprocessing.py
# -*- coding: utf-8 -*-
"""Data Preprocessing.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1W5Ipe_XX0MZrlF83ytB_TRNqQZl0GDA_
"""

import pandas as pd
import numpy as np
Average = np.zeros([39,8])
sd = np.zeros([39,8])
V70arr = np.zeros(39)
V60 = 0
for i in range(1,40):
  if i < 10 :
    data = pd.read_csv("live0"+ str(i) +".csv")
  else:
    data = pd.read_csv("live"+ str(i) +".csv")
  if i<5 or i>12:
    data = data.shift(1,axis = 1)
  data = data.drop(columns = ['ENGINE_RUN_TINE ()','COMMANDED_EVAPORATIVE_PURGE ()', 'TIME_RUN_WITH_MIL_ON ()','TIME_SINCE_TROUBLE_CODES_CLEARED ()',
       'DISTANCE_TRAVELED_WITH_MIL_ON ()', 'WARM_UPS_SINCE_CODES_CLEARED ()','FUEL_TANK ()', 'ABSOLUTE_THROTTLE_B ()', 'PEDAL_D ()', 'PEDAL_E ()',
       'COMMANDED_THROTTLE_ACTUATOR ()', 'FUEL_AIR_COMMANDED_EQUIV_RATIO ()',
       'ABSOLUTE_BAROMETRIC_PRESSURE ()', 'RELATIVE_THROTTLE_POSITION ()',
       'INTAKE_AIR_TEMP ()', 'TIMING_ADVANCE ()',
       'CATALYST_TEMPERATURE_BANK1_SENSOR1 ()',
       'CATALYST_TEMPERATURE_BANK1_SENSOR2 ()', 'CONTROL_MODULE_VOLTAGE ()'])
  for j in range(len(data.columns)):
    Average[i-1][j] = pd.DataFrame.mean(data[data.columns[j]])
    sd[i-1][j] = pd.DataFrame.std(data[data.columns[j]])
    if data.columns[j]== 'VEHICLE_SPEED ()':
      data = data.reset_index(drop=True)
      speed = np.array(data['VEHICLE_SPEED ()'])
      if i==4:
        m = speed
      l= 0
      for k in range(len(speed)):
        if speed[k]> 70:
          l= l+1
         # if i==5:
          #  print(k)
      V60 = (l/len(speed))*100
  V70arr[i-1] = V60
# -*- coding: utf-8 -*- Data Preprocessing.ipynb  Automatically generated by Colaboratory.  Original file is located at     https://colab.research.google.com/drive/1W5Ipe_XX0MZrlF83ytB_TRNqQZl0GDA_ # if i==5: #  print(k)