I have a Excel sheet with 10000 Rows. I have to change the value of a Colum5 based on value of Colum2 and update the excel sheet.
I am able to change the values using:
import numpy as np
df=pd.read_excel('part2.xlsx')
count=0
while (count<10000):
if df['Grade'][count] == 'A' :
#df.loc[df['Grade'][count]] = 'Good'
df['Grade'][count] = 'Good'
print(count)
print(df['Grade'][count])
count=count+1
df.to_excel('temp.xlsx')
The issue with this is as I am writing to a new Excel sheet all the formatting is gone. I want to achieve the same thing in the same excelsheet so that format is not removed.
2) is there any use in keeping the df.loc here?