aixd.data.utils_data.reformat_dictlist_to_dict

aixd.data.utils_data.reformat_dictlist_to_dict(dictlist: List[Dict]) Dict[source]

The input is a list of dictionaries, where each dictionary, e.g., corresponds to one data sample and the keys correspond to the data object names. This method reformats it into one dictionary where the values from all samples are collated under the same key.

Parameters:

dictlist (List[dict]) – List of dictionaries.

Returns:

Dict – Single collated dictionary.

Examples

>>> dictlist = [{'a': [1, 1], 'b': 2, 'c': 3}, {'a': [7, 7], 'b': 8, 'c': 9}]
>>> reformat_dictlist_to_dict(dictlist)
{'a': [[1, 1], [7, 7]], 'b': [2, 8], 'c': [3, 9]}