replace string if it contains a substring pandas

Solutions on MaxInterview for replace string if it contains a substring pandas by the best coders in the world

showing results for - "replace string if it contains a substring pandas"
Anael
29 Aug 2017
1df_a.loc[df_a.categories.str.contains('beverage'), 'categories'] = 'beverage'
2
3
4    categories      product_name
50   beverage        coca-cola
61   salty snacks    salted pistachios
72   beverage        fruit juice
83   beverage        lemon tea
94   salty crackers  roasted peanuts
10