How to replace values in a Pandas DataFrame column based on a conditional expression in Python Use DataFrame.loc() Use np.where()