我有一个计数器,目前我使用以下内容打印出每个单词的长列表及其相应的出现频率:
from collections import Counter
import matplotlib.pyplot as plt
import pandas as pd
data = []
with open('csv.csv') as f:
data = [word for row in csv.reader(f) for word in row[1].lower().split()]
counts = Counter(data)
for value, count in counts.most_common():
print(value, count)
我想以散点图或条形图格式查看数据。我对解决方案Using Counter() in Python to build histogram?的问题在于,它会抛出一个错误,即我的所有字符串都不是unicode,只显示一个最大长度的条。