我在下面数据.csv你知道吗
custId,contract,zone,teamcode,projectcode,time
2,2345,us_east,Red,A,5s
1,2345,us_west,Blue,B,1s
2,2346,eu_west,Yellow,C,2s
1,2345,us_west,Blue,D,1s
3,2346,eu_west,Yellow,E,2s
我不想在这里用熊猫。你知道吗
我是python的新手,我不知道如何解决这个问题。我设法用csv读取数据,但我不知道下一步该怎么做。你知道吗
import csv
with open('data.csv', 'r') as f:
reader = csv.reader(f)
for row in reader:
print(row)
编辑:我需要找到每个合同的唯一custId编号。你知道吗
我想你应该计算一下每个合同中有多少客户。你知道吗
如果是这样的话,那么这里是如何做到这一点,不使用熊猫
输出:
看起来你需要
collections.defaultdict
和set
。你知道吗例如:
输出:
相关问题 更多 >
编程相关推荐