arr = [ { "date": "2022-2-7", "other": [123] },
{ "date": "2022-2-7", "other": [456] },
{ "date": "2022-2-8", "other": [789] } ]
def delete_repeats(arr):
new_dict = {}
for i in arr:
if not i['date'] in new_dict.keys():
new_dict[i['date']] = i['other']
else:
new_dict[i['date']] += i['other']
return new_dict
def make_formatted(arr):
new_arr = []
for i in arr:
new_arr.append({'date': i, 'data': arr[i]})
return new_arr
print(make_formatted(delete_repeats(arr)))
>> [{'date': '2022-2-7', 'data': [123, 456]}, {'date': '2022-2-8', 'data': [789]}]