I would like to group by year and city, while cumulating dates and pts as on the output, I am new to python and have no idea how to go about it, would you have any idea please? I extracted the lists list_year and list_city, not sure if this is useful? Thank you
list_pts = [
{'city' : 'Madrid', 'year' : '2017', 'date' : '05/07/2017', 'pts' : 7},
{'city' : 'Madrid', 'year' : '2017', 'date' : '14/11/2017', 'pts' : 5},
{'city' : 'Londres', 'year' : '2018', 'date' : '25/02/2018', 'pts' : 5},
{'city' : 'Paris', 'year' : '2019', 'date' : '17/04/2019', 'pts' : 4},
{'city' : 'Londres', 'year' : '2019', 'date' : '15/06/2019', 'pts' : 8},
{'city' : 'Paris', 'year' : '2019', 'date' : '21/08/2019', 'pts' : 8},
{'city' : 'Londres', 'year' : '2019', 'date' : '04/12/2019', 'pts' : 2}]
list_year = ['2017', '2018', '2019']
list_city = ['Paris', 'Madrid', 'Londres']
output =
[{'year' : '2017', 'city' : 'Madrid', 'date' : ['05/07/2017', '14/11/2017'], 'pts' :[5, 7]},
{'year' : '2018', 'city' : 'Londres', 'date' : ['25/02/2018'], 'pts' :[5]},
{'year' : '2019', 'city' : 'Londres', 'date' : ['15/06/2019', '04/12/2019'], 'pts' :[8, 2]},
{'year' : '2019', 'city' : 'Paris', 'date' : ['17/04/2019', '21/08/2019'], 'pts' :[4, 8]}]