Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = {'Account balances': [{'2008-04-04': 252216},
- {'2010-05-17': 3619948},
- {'2010-10-25': 590954},
- {'2014-10-01': 568340},
- {'2016-09-04': 2424784},
- {'2018-08-25': 261463}],
- 'Address book contacts': [{'2017-12-05': 20580060}],
- 'Age groups': [{'2014-02-17': 37784}, {'2017-12-31': 84011}],
- 'Ages': [{'2014-09-01': 1287073}],
- 'Apps installed on devices': [{'2017-12-05': 20580060}],
- 'Astrological signs': [{'2016-02-29': 27393015}],
- 'Audio recordings': [{'2018-08-16': 44109}],
- 'Auth tokens': [{'2016-08-07': 2247314}, {'2019-01-03': 17204697}],
- 'Avatars': [{'2016-02-21': 144989},
- {'2016-02-29': 1535473},
- {'2016-05-18': 1531235},
- {'2016-05-28': 97151},
- {'2017-11-28': 512311}],
- 'Bank account numbers': [{'2015-07-01': 88678}, {'2018-10-21': 242715}],
- 'Beauty ratings': [{'2015-11-11': 1100089}],
- 'Biometric data': [{'2016-03-27': 228605}],
- 'Bios': [{'2018-02-28': 19611022}],
- 'Browser user agent details': [{'2008-04-04': 252216},
- {'2013-01-04': 179967},
- {'2016-05-20': 104977},
- {'2016-12-15': 400260},
- {'2018-07-09': 1279263},
- {'2018-08-24': 411755},
- {'2018-12-28': 7633234}],}
- for key, value in data.items():
- total = sum(v for row in value for k, v in row.items())
- print(key, total) # Or add to new data structure?
- from copy import deepcopy
- data_copy = deepcopy(data)
- for key in data_copy:
- list_of_dicts = data_copy[key]
- list_of_tuples = [list(dct.items())[0] for dct in list_of_dicts]
- new_dict = dict(list_of_tuples)
- data_copy[key] = new_dict
- print(data_copy)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement