1
import pandas as pd
GDP=pd.read_csv('world_bank.csv')
for i in GDP.index:
    if GDP.iloc[i]['Data Source']=="Korea, Rep.":
        GDP.iloc[i]['Data Source']="South Korea"

I tried to run the above code. But it does not update the string. And does not show any error. The "ABW" data point is present in the dataframe. I also have given the link of the dataset. https://github.com/pran9957/world-bank-data.git

1 Answers1

1

Use Series.replace:

GDP['Data Source'].replace({
    'Korea, Rep.': 'South Korea'
}, inplace=True)
Code Different
  • 73,850
  • 14
  • 125
  • 146