I am trying to use a while loop to read through all the rows of my file and edit the value of a particular cell when a condition is met.
My logic is working just fine when I am reading data from an excel. But same logic is not working when I am reading from a csv file.
Here is my logic to read from Excel file:
df = pd.read_excel('Energy Indicators.xls', 'Energy', index_col=None, na_values=['NA'], skiprows = 15, skipfooter = 38, header = 1, parse_cols ='C:F')
df = df.rename(columns = {'Unnamed: 0' : 'Country', 'Renewable Electricity Production': '% Renewable'})
df = df.drop(0, axis=0)
i = 0 
while (i !=len(df)):
    if df.iloc[i]['Country'] == "Ukraine18":
        print(df.iloc[i]['Country'])
        df.iloc[i]['Country'] = 'Ukraine'
        print(df.iloc[i]['Country'])
    i += 1
df
The result I get is:
Ukraine18
Ukraine
But when I read a CSV file:
df = pd.read_csv('world_bank.csv', skiprows = 4)
df = df.rename(columns = {'Country Name' : 'Country'})
i = 0 
while (i !=len(df)):
    if df.iloc[i]['Country'] == "Aruba":
        print(df.iloc[i]['Country'])
        df.iloc[i]['Country'] = "Arb"
        print(df.iloc[i]['Country'])
    i += 1
df
The result I get is:
Aruba
Aruba
Can someone please help? What am I doing wrong with my CSV file?

