Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lista = [['Day', 'Cost', 'Clicks'], ['2019-03-21', 50300.0, 39], ['2019-03-21', 49270.0, 307], ['2019-03-21', 23630.0, 15], ['2019-03-21', 150110.0, 525], ['2019-03-21', 12120.0, 33], ['2019-03-21', 605330.0, 4033], ['2019-03-21', 1040490.0
- , 4435], ['2019-03-21', 191390.0, 758], ['2019-03-21', 42230.0, 155], ['2019-03-21', 305110.0, 760], ['2019-03-22', 164150.0, 642], ['2019-03-22', 3717300.0, 17370], ['2019-03-23', 39130.0, 65], ['2019-03-23', 3717300.0, 17370], ['2019-03-24', 39130.0, 65]]
- def sumByDate(list):
- newList = [[list[0][0], list[0][1], list[0][2]], [list[1][0], 0, 0]]
- j = 1
- for i in range(1, len(list)):
- if (newList[j][0] == list[i][0]):
- newList[j] = [newList[j][0], newList[j][1] + list[i][1], newList[j][2] + list[i][2]]
- else:
- newList.append([list[i][0], list[i][1], list[i][2]])
- j += 1
- return(newList)
- print(sumByDate(lista))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement