Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Mon Sep 30 20:06:52 2024
- @author: Sanjit-Aero
- """
- import pandas as pd
- df = pd.read_csv('input.csv')
- colNames = df.columns
- idximp = [index for index, value in enumerate(colNames) if value.startswith('Column')]
- totNegList = []
- for i in range(len(df)):
- temSum=0
- for idx in idximp:
- try:
- if df.iloc[i,idx]==df.iloc[-1,idx]:
- df.iloc[i,idx+2]=5
- temSum = temSum + 5
- elif df.iloc[i,idx].startswith('Option'):
- df.iloc[i,idx+2]=-1
- temSum = temSum - 1
- except:
- pass
- totNegList.append(temSum)
- idxfeed = [3,4,5]
- idxfeed.extend([index for index, value in enumerate(colNames) if value.startswith('Feedback - Column')])
- FeedDF = df.iloc[:, idxfeed]
- FeedDF.insert(3, 'total_after_negative', totNegList)
- df.to_csv('output_v1.csv')
- FeedDF.to_csv('output_v2.csv')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement