首页 > 解决方案 > 可视化 Pandas 系列中出现频率最高的单词

问题描述

我有一个熊猫系列,想绘制最常用的词。

我的系列已经被标记并删除了停用词。

series

0        [laptop, sit, 4, star, similarly, price, compa...
1        [order, monitor, want, makeshift, area, powerf...
2        [monitor, great, deal, price, size, ., use, of...
3        [buy, height, adjustment, ., swivel, ability, ...
4        [work, month, die, ., 5, call, hp, support, nu...
                               ...                        
30618                                        [great, deal]
30619                                  [pour, le, travail]
30620                                      [business, use]
30621                                         [good, size]
30622    [pour, mon, ordinateur.plus, grande, image.vra...
Name: text_body, Length: 30623, dtype: object

我想使用 seaborn 来绘制代表热门单词的图表。

counter=Counter(str(series))
most=counter.most_common()
x=[]
y=[]
for word,count in most[:20]:
        x.append(word)
        y.append(count)

sns.set(rc={'figure.figsize':(10,10)})
sns.barplot(x=y,y=x)

最常用词

该图仅显示顶部字符而不是单词。我做错了什么?

标签: pythonpandasseaborndata-visualization

解决方案


推荐阅读