我试图为一个keyword vs frequency
列表绘制一个简单的bar plot
。
由于数据没有header
,我无法使用Pandas
或{
输入
#kyuhyun,1
#therinewyear,4
#lingaa,2
#starts,1
#inox,1
#arrsmultiplex,1
#bollywood,1
#kenya,1
#time,1
#watch,1
#malaysia,3
代码:
^{pr2}$我只想绘制一个条形图,其中x axis
作为关键字,y axis
表示频率。任何简单的方法来描绘这一切都将是巨大的帮助。在
下面的解决方案似乎很有魅力,但我有太多的关键字在一个列表中,我正在寻找一个选择,如果我可以只绘制前10-20个关键字与各自的关键字,这样条形图将看起来更好。在
答案中给出的解决方案的输出。在
不回答您的问题,但pandas不要求数据具有标题。 若从文件中读取数据,只需选择header=None(more infohere)。在
例如,您还可以将数据作为字典传递
^{pr2}$我不熟悉
np.genfromtxt
,但我怀疑问题是当x
应该是数值时,它将x
作为字符串数组返回。在或许可以尝试一下:
相关问题 更多 >
编程相关推荐