aixd.data.utils_data.reformat_list_to_dictlist
- aixd.data.utils_data.reformat_list_to_dictlist(nested_list: List[List], dataobjects: List[DataObject]) List[Dict] [source]
Reformats data formatted as a nested list into a list of dictionaries. Each item in the list corresponds to one sample and contains a flattened list of values (no further sub-lists). The purpose of this method is to associate the data with names and collapse to their original dimensions. The information about the original dimensions and names of the data objects is drawn from the given list of dataobjects. The order of the provided data objects must match the data in the nested list.
- Parameters:
nested_list (List[List]) – List of lists, containing data.
dataobjects (List[DataObject]) – List of data objects from which names and dimensions will be recovered.
- Returns:
List[Dict] – Data in form of a list of dictionaries.
Examples
>>> from aixd.data.data_objects import DataInt >>> a = DataInt(name = "a", dim=2) >>> b = DataInt(name = "b", dim=1) >>> c = DataInt(name = "c", dim=1) >>> nested_list = [[1,1, 2, 3], [7,7,8,9]] >>> reformat_list_to_dictlist(nested_list, [a,b,c]) [{'a': [1, 1], 'b': 2, 'c': 3}, {'a': [7, 7], 'b': 8, 'c': 9}]