我有三张单子
year= [2001, 2002, 2005, 2002, 2004, 2001, 2001, 2002, 2003, 2003, 2002, 2002, 2003, 2004, 2005, 2003, 2004, 2005, 2004, 2004 ]
indviduals= [12, 23, 24, 28,30, 15, 17, 18, 18, 19, 12, 15, 12, 12, 12, 15, 15, 15, 12, 12]
employers= ['a', 'b', 'c', 'd', 'e', 'a', 'a', 'b', 'b', 'c', 'b', 'a', 'c', 'd', 'e', 'a', 'a', 'a', 'a', 'b']
当我运行下面的脚本时,我可以得到列表中的每个员工。我想做的是
a:[12, 15, 17, 15]
2001年
如果我能做到这一点,我认为得到计数只是长度。你知道吗
for index, item in enumerate(year):
for i in np.unique(employers[index]):
count=0
#print(i)
#j=indviduals[index]
count +=1
print(i)
你可以用列表理解
查找雇主列表中匹配元素为“a”的所有个人
如果你想数一数
否则,我建议使用一个元组列表,这样可以更容易地进行筛选,而不是存储并行列表
为你所有的雇主做这件事怎么样?使用内置dict的方法^{}
哪个指纹
相关问题 更多 >
编程相关推荐