I have a df,
Name Step Description
Ram 1 Ram is oNe of the good cricketer
Ram 2 gopal one
Sri 1 Sri is one of the member
Sri 2 ravi good
Kumar 1 Kumar is a keeper
Madhu 1 good boy
Vignesh 1 oNe little
Pechi 1 one book
mario 1 good randokm
Roger 1 one milita good
bala 1 looks good
raj 1 more one
venk 1 likes good
and a list,
my_list=["one","good"]
I am trying to get the rows which are having atleast one keyword from my_list.
I tried, mask=df["Description"].str.contains("|".join(my_list),na=False) I am getting the output_df,
Name Description
Ram Ram is one of the good cricketer
Sri Sri is one of the member
I also want to add the keywords present in the "Description" and its counts in a separate columns,
Even the "Description" contains a keyword when the df["Name"] is not a first time occureance it should not copy the keyword in keys column My desired output is,
my_desired output is,
Name Step Description keys count
Ram 1 Ram is one of the good cricketer one,good 2
Ram 2 gopal one
Sri 1 Sri is one of the member one 1
Sri 2 ravi good
Kumar 1 Kumar is a keeper
Madhu 1 good boy good 1
Vignesh 1 oNe little oNe 1
Pechi 1 one book one 1
mario 1 good randokm good good 1
Roger 1 one milita good one,good 2
bala 1 looks good good 1
raj 1 more one one 1
venk 1 likes good good 1