xxxxxxxxxx
df.replace([np.inf, -np.inf], np.nan)
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
# this will replace "Boston Celtics" with "Omega Warrior"
df.replace(to_replace ="Boston Celtics",
value ="Omega Warrior")