I have a for loop that loops through a set of students in a dataframe and gets back their ID and Attendance:
for i in FinalDataset.index:
student = FinalDataset.loc[i,'students']
AttendanceSoFar = FinalDataset.loc[i,'OverallAttCurrent']
data = [[student, AttendanceSoFar]]
InsertionData = pd.DataFrame(data, columns=['student', 'AttendanceSoFar'])
InsertionData.to_excel("Result.xlsx")
I then put these details in a dataframe called InsertionData and create an excel spreadsheet with that data in. However currently it creates multiple spreadsheets. I just want to add a new row each time it loops. Does anyone know how to do this?
P.S - In my actual code I am also performing multiple calculations and adding new variables, which is why I can't just delete columns in the current dataframe and use that.