我尝试计算主列表中子列表中的每个事件并制作图表

时间:2018-12-10 20:41:00

标签: python pandas list data-visualization

这是列表:

for i in programming_skills_list:
    print i
 output: ['SQL', 'C', 'Excel']
['R', 'SQL', 'C']
['SQL', 'C']
['R', 'SQL', 'C']
['SQL', 'C']
['R', 'C']
['R', 'C']
['R', 'C', 'Excel']
['R', 'SQL', 'C', 'Excel']
['R', 'Tableau', 'SQL', 'C']
['R', 'Tableau', 'SQL', 'C', 'Excel']
['R', 'C', 'Excel', 'Office']
['R', 'C', 'Excel', 'Office']
['R', 'C', 'Excel', 'Office']
['R', 'C', 'Excel', 'Office']
['SQL']
['R', 'Tableau', 'SQL', 'C']
['R', 'Tableau', 'SQL', 'C', 'Excel']
['Tableau', 'SQL', 'C', 'Excel']
['R', 'SQL', 'C']
['R', 'C', 'Excel', 'Office']
['R', 'C', 'Excel', 'Office']
['R', 'C']
['R', 'C']
['R', 'C']
['R', 'C']
['SAS', 'R', 'C', 'Excel']
['SAS', 'R', 'Tableau', 'SQL', 'C', 'Excel', 'JMP']
['R', 'C', 'Excel']
['R', 'C', 'Excel', 'Office']
['R', 'SQL', 'C']
['R', 'SQL', 'C']
['R', 'C', 'Excel', 'Office']
['SAS', 'R', 'C']
['R', 'C', 'Excel', 'Office']
['R', 'C', 'Visual Basic', 'Excel']
['R', 'C', 'Visual Basic', 'Excel']
['SAS', 'R', 'SQL', 'C']
['SAS', 'R', 'SQL', 'C']
['SAS', 'R', 'SQL', 'C']
['R', 'C']
['R', 'SQL', 'C', 'Excel']
['SAS', 'R', 'SQL', 'C', 'Excel']
['R', 'C', 'Excel']
['R', 'C', 'Excel']
['R', 'C', 'Excel']
['R', 'C', 'Excel']
['R', 'Tableau', 'SQL', 'C', 'Excel']
['R', 'C', 'Excel', 'Office']
['R', 'C', 'Excel', 'Office']
['R', 'C', 'Excel', 'Office']
['R', 'C']
['R', 'C']
['R', 'C']
['R', 'C', 'Excel', 'Office']
['R', 'C', 'Excel', 'Office']
['R', 'C', 'Excel', 'Office']
['R', 'C', 'Excel', 'Office']
['R', 'C', 'Excel', 'Office']
['R', 'SQL', 'C']

子列表的总数是60。我想计算每种技能类型,并制作一张图表,显示60个工作样本中最需要的技能。我尝试使用If语句进行计数,但出现错误,指出该列表不可散列。

1 个答案:

答案 0 :(得分:1)

我们可以使用熊猫来获取价值计数和绘图:

import pandas as pd
programming_skills_list = #however you defined that list of list above#
s = pd.Series(sum(programming_skills_list, []))
s.value_counts().plot.bar()

输出:

enter image description here