具有一个包含df
的数据框column (A)
如下
A
["User mapping missing constantly for random users on product PLA-ZA. Hi,Generally,these results look encouraging. Here's what I see at the moment:- On Sept 12,when you ran this script,exactly the same users were shown as not "in sync" as we see in the most recent output."
"History ------------ *** Audit: MLACAMBR 01/10/2018 18:40:05 GMT ","1. find the process ids by doing ps -efl | grep BEMS74397","kill each of these processes,as follows (for example,if the process ID is 555555):","Troubleshoots from the KMCas well as from the sensor where the connections occurred"]
和Python列表匹配
["PLA-ZA","BEMS","MLACAMBR","KMC","OWL",]
Dataframe
需要添加一个新的column B
来匹配列表中的字符串
具有匹配关键字的新数据框已添加为新列
matches= "|".join(f"\\b{i}\\b" for i in matches)
df["B"] = df['text'].str.findall(matches,re.IGNORECASE).str.join("|")
df["B"]