按列表中的项目分组

时间:2013-08-23 08:59:35

标签: python list python-2.7

>>> with open('Book2.csv', 'rb') as f:
    inpreader = csv.reader(f, delimiter=',')
    for row in inpreader:
        print ','.join(row)

IdNo, skillsList
BAXA0000206_NEENA_TIWARI_0.htm,[u'Training', u'E-Learning', u'PowerPoint', u'Teaching', u'Accounting', u'Team Management', u'Team Building', u'Microsoft Excel', u'Microsoft Office', u'Financial Accounting', u'Microsoft Word', u'Customer Service']
BAXA0000227_ABDUR_RAZZAQUE_0.htm,[u'Telecommunications', u'Data Center', u'ISO 27001', u'Management', u'BS25999', u'Technology', u'Information Technology...', u'Certified PMP\xae', u'Certified BS25999 Lead...']
BAXA0000261_Priya _ Lobo_0.htm,[u'Market Research', u'Segmentation', u'Marketing Strategy', u'Consumer Behavior', u'Experience Working with...']

我想找出技能列表中每项技能的术语频率。我该怎么办...

由于

1 个答案:

答案 0 :(得分:0)

counter = {}
for skill_list in lists:
    for skill in skill_list:
        counter[skill] = counter.get(skill, 0) + 1

print counter