我们的目标是创建一个堆叠的条形图,显示推特(我从tweepy那里得到的)在360秒(每秒)内的情绪。我有两张单子。第一个是按时间顺序对推文进行情感分析,第二个是按时间顺序对每秒推文的数量进行分析
list1 = ("neg", "pos", "pos", "neu", "neg", "pos", "neu", "neu",...)
list2 = (2, 1, 3, 2,...)
现在,我想创建某种嵌套循环,并使用list2来计算列表1中的项目。然后,我将有3个列表,其中每个情绪都有360个值,可以用于图表。它应该给我一个类似的输出:
lis_negative = (1, 0, 1, 0, ...)
lis_positive = (1, 1, 1, 0, ...)
lis_neutral = (0, 0, 1, 2, ...)
我如何创建这个循环?是否有更简单的方法?除了matplotlib之外,我更愿意不使用任何库
代码:
演示:
根据要求,无导入的解决方案:
编辑:更短导入更少解决方案:
相关问题 更多 >
编程相关推荐