【发布时间】:2018-05-05 09:27:49
【问题描述】:
我有一个大约 150 万行的 pandas 数据框。我想在某个列中找到特定的选定单词(都是已知的)的出现次数。这适用于一个单词。
d = df["Content"].str.contains("word").value_counts()
但我想从列表中找出多个已知单词的出现次数,例如“word1”、“word2”。 word2 也可以是 word2 或 wordtwo,如下所示:
word1 40
word2/wordtwo 120
我该如何做到这一点?
【问题讨论】:
-
你有单词列表吗?
-
是的,我有整个列表
标签: python pandas dataframe find-occurrences