pandas: replace string with another string

Solution with replace by dictionary:

df['prod_type'] = df['prod_type'].replace({'respon':'responsive', 'r':'responsive'})
print (df)
    prod_type
0  responsive
1  responsive
2  responsive
3  responsive
4  responsive
5  responsive
6  responsive

If need set all values in column to some string:

df['prod_type'] = 'responsive' 

Leave a Comment