xxxxxxxxxx
df['coloum'] = df['coloum'].replace(['value_1','valu_2'],'new_value')
xxxxxxxxxx
# Replace missing values
df["col"].replace(np.nan, new_val)
# Replace other values
df["col"].str.replace('old','new')
# Replace using masking
df.loc[df['col']=='old', 'col'] = 'new'
# Replace all specified value in the dataframe
df_replaced = df.replace(1, 0)
xxxxxxxxxx
df.loc[df['column_name'] == value_you_want_replaced, 'column_name'] = your_value
xxxxxxxxxx
energy['Country'] = energy['Country'].replace(['Afghanistan','Albania'],['Sa','lol'])
xxxxxxxxxx
df['column name'] = df['column name'].replace(['old value'], 'new value')