Python 提取最常见的单词作为WordCloud清理?
我想用Python 提取最常见的单词作为WordCloud清理?,python,pandas,nltk,Python,Pandas,Nltk,我想用[Word,Count]作为列来提取数据帧中最常见的单词 结果应该与WordCloud中给出的结果相似,因为您可以看到只考虑了相关的单词。因此,没有停止词,多个词的项目,并保持大写 我试过用计数器,但结果只考虑单个单词和词尾仍然存在。 x = Counter(' '.join(df['name']).split()).most_common(20) pd.DataFrame(x, columns=['word', 'count']) word count 0 in
[Word,Count]
作为列来提取数据帧中最常见的单词
结果应该与WordCloud
中给出的结果相似,因为您可以看到只考虑了相关的单词。因此,没有停止词,多个词的项目,并保持大写
<>我试过用计数器,但结果只考虑单个单词和词尾仍然存在。
x = Counter(' '.join(df['name']).split()).most_common(20)
pd.DataFrame(x, columns=['word', 'count'])
word count
0 in 8875
1 Private 3224
2 Room 2925
3 to 2645
4 room 2512
5 Bedroom 2404
6 Cozy 2324
7 2 2255
8 Brooklyn 2099
9 Apartment 2075
10 & 1966
12 Manhattan 1824
11 1 1885
13 with 1815
14 and 1714
15 of 1703
16 the 1700
17 Studio 1638
18 bedroom 1615
19 - 1567
比如前10名?。您可以使用
ntlk
删除stopwords,例如使用本例中的类似内容