I have a pandas dataframe A with column keywords as :-
keywords
['loans','mercedez','bugatti','a4']
['trump','usa','election','president']
['galaxy','7s','canon','macbook']
['beiber','spiderman','marvels','ironmen']
.........................................
.........................................
.........................................
I also have another pandas dataframe B with column category and words which is comma seperated string as:-
category words
audi audi a4,audi a6
bugatti bugatti veyron, bugatti chiron
mercedez mercedez s-class, mercedez e-class
dslr canon, nikon
apple iphone 7s,iphone 6s,iphone 5
finance sales,loans,sales price
politics donald trump, election, votes
entertainment spiderman,captain america, ironmen
music justin beiber, rihana,drake
........ ..............
......... .........
All I want to map dataframe A column keywords with dataframe B column words and assign a corresponding category. Mapping of keywords column should be with each word in string of column word. For example:- keyword a4 should be matched with both words in string audi a4 in column words.Expected result would be:-
keywords matched_category
['loans','mercedez','bugatti','a4'] ['finance','mercedez','mercedez','bugatti','bugatti','audi']
['trump','usa','election','president'] ['politics','politics']
['galaxy','7s','canon','macbook'] ['apple','dslr']
['beiber','spiderman','marvels','ironmen'] ['music','entertaiment','entertainment','entertainment']