Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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
Comment

PREVIOUS NEXT
Code Example
Python :: how to encode hexadecimal python 
Python :: py env 
Python :: creating a list in python 
Python :: tkinter entry 
Python :: train test split 
Python :: get hash python 
Python :: add system path python jupytre 
Python :: how to disconnect wifi using python 
Python :: python basic flask app 
Python :: python list only files not directories 
Python :: dataframe create 
Python :: ta-lib python install 
Python :: flask error 
Python :: repeat array along new axis 
Python :: hstack in numpy 
Python :: django clear all sessions 
Python :: read a file in python 
Python :: how to get current latitude and longitude in python 
Python :: batchnorm1d pytorch 
Python :: find character in python 
Python :: tensor to int python 
Python :: how to round an array in python 
Python :: how to create a matrix using python 
Python :: openpyxl full tutorial 
Python :: django set random password 
Python :: user input python 
Python :: python logging into two different files 
Python :: discord py get all channels in guild 
Python :: comment in python 
Python :: create a blank image cv2 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =