I appreciate the help.
I have two data sets:
models = pd.DataFrame({"manufacturer":['Nokia', 'Samsung', 'Motorola', 'Nokia', 'Alcatel', 'Nokia 5'],
"model":['3310', 'S4', 'Moto G', 'N1', 'Pixy', 'Nokia 5']})
data = pd.DataFrame({"title":["Brand New Nokia 3310", "Old Samsung S4", "Cool Motorola Moto G", 'New Alcatel', 'Old Nokia 5'],
"manufacturer":['Nokia', "Samsung", "Motorola", 'Alcatel', 'Nokia'],
"model":["placeholder", "placeholder", "placeholder", "placeholder", "placeholder"]})
I need to populate model value in data['model'] by condition that the string in title contains model string, otherwise the value in that column should remain placeholder.
I tried to do it by using a list comprehension but it's not working.
mod = models["model"].tolist()
title = data['title']
data['model'] = pd.Series([m for m in mod for t in title if m in]
I also tried by using "str.contains" which is pandas method:
for m in mod:
if title.str.contains(m):
data['model'] = m
But that also is not working as i expected. Is there a way to do it? Thanks in advance.