Answers for "replace substring in string pandas"

1

pandas replace string with another string

df['prod_type'] = df['prod_type'].replace({'respon':'responsive', 'r':'responsive'})
Posted by: Guest on June-10-2021
0

replace string if it contains a substring pandas

df_a.loc[df_a.categories.str.contains('beverage'), 'categories'] = 'beverage'


    categories      product_name
0   beverage        coca-cola
1   salty snacks    salted pistachios
2   beverage        fruit juice
3   beverage        lemon tea
4   salty crackers  roasted peanuts
Posted by: Guest on March-28-2021

Code answers related to "replace substring in string pandas"

Python Answers by Framework

Browse Popular Code Answers by Language