我有一个df,
Name Description
Ram Ram is one of the good cricketer
Sri Sri is one of the member
Kumar Kumar is a keeper
和一个清单,
my_list=["一","好","拉维","球"]
我正在尝试从 my_list 中获取至少具有一个关键字的行。
I tried,
mask=df["Description"].str.contains("|".join(my_list),na=False)
我得到了output_df,
Name Description
Ram Ram is one of ONe crickete
Sri Sri is one of the member
Ravi Ravi is a player, ravi is playing
Kumar there is a BALL
我还想添加“描述”中存在的关键字及其在单独列中的计数,
我想要的输出是,
Name Description pre-keys keys count
Ram Ram is one of ONe crickete one,good,ONe one,good 2
Sri Sri is one of the member one one 1
Ravi Ravi is a player, ravi is playing Ravi,ravi ravi 1
Kumar there is a BALL ball ball 1