The dataframe has 2 columns: sentence and list. The requirement is to replace the string in df['sentence'] which is present in df['list'] with string found|present.
from pandas import DataFrame
df = {'list': [['Ford','Mercedes Benz'],['ford','hyundai','toyota'],['tesla'],[]],
'sentence': ['Ford is less expensive than Mercedes Benz' ,'toyota and hyundai mileage is good compared to ford','tesla is an electric car','toyota too has electric cars']
}
df = DataFrame(df,columns= ['list','sentence'])
The expected output for df['sentence'] is:
Ford|present is less expensive than Mercedes Benz|present
toyota|present and hyundai|present mileage is good compared to ford|present
tesla|present is an electric car
toyota too has electric cars
toyota too has electric carswas not modified?