Advertisement
mayankjoin3

Microsoft team quiz negative marking scores Sanjit

Sep 30th, 2024
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Mon Sep 30 20:06:52 2024
  4.  
  5. @author: Sanjit-Aero
  6. """
  7.  
  8. import pandas as pd
  9.  
  10. df = pd.read_csv('input.csv')
  11.  
  12. colNames = df.columns
  13.  
  14. idximp = [index for index, value in enumerate(colNames) if value.startswith('Column')]
  15.  
  16. totNegList = []
  17. for i in range(len(df)):
  18.     temSum=0
  19.     for idx in idximp:
  20.         try:
  21.             if df.iloc[i,idx]==df.iloc[-1,idx]:
  22.                 df.iloc[i,idx+2]=5
  23.                 temSum = temSum + 5
  24.             elif df.iloc[i,idx].startswith('Option'):
  25.                 df.iloc[i,idx+2]=-1
  26.                 temSum = temSum - 1
  27.         except:
  28.             pass
  29.     totNegList.append(temSum)
  30.  
  31. idxfeed = [3,4,5]
  32. idxfeed.extend([index for index, value in enumerate(colNames) if value.startswith('Feedback - Column')])
  33.  
  34. FeedDF = df.iloc[:, idxfeed]
  35. FeedDF.insert(3, 'total_after_negative', totNegList)
  36.  
  37. df.to_csv('output_v1.csv')
  38. FeedDF.to_csv('output_v2.csv')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement