text: # -*- coding: utf-8 -*-
  """average_Ratings.ipynb
  
  Automatically generated by Colaboratory.
  
  Original file is located at
      https://colab.research.google.com/drive/1_aAjMLGaaNzcy_ib3lRD4x3H0S3Dpcyi
  """
  
  import pandas as pd
  
  #input: a csv file containing the input ratings
  #returns a dataframe containing the average ratings for each response
  def average_ratings(ratings):
    df = pd.read_csv(ratings)
    avg = df[['Input.Stressor1','Input.Response1','Answer.rating_1']].rename(columns={'Input.Stressor1': 'Stressor', 'Input.Response1': 'Response', 'Answer.rating_1':'rating'})
    for i in range(2,4):
      avg = avg.append(df[['Input.Stressor' + str(i),'Input.Response' + str(i),'Answer.rating_' + str(i)]].rename(columns={'Input.Stressor' + str(i): 'Stressor', 'Input.Response'  + str(i): 'Response', 'Answer.rating_' + str(i) :'rating'}))
    avg = avg.groupby(by=['Stressor','Response']).mean()
    return avg
  d = average_ratings('/rating_hit_results.csv')
  d.to_csv('average_ratings.csv')
  