aixd.data.utils_data.reformat_list_to_dataframe
- aixd.data.utils_data.reformat_list_to_dataframe(nested_list: List[List], dataobjects: List[DataObject]) pd.DataFrame [source]
Reformats data formatted as a nested list of data into a dataframe. 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 recover an unflattened dataframe. The information about the original dimensions and names of the data objects is drawn from the given list of data objects. 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:
pd.DataFrame – Recovered unflattened dataframe.
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_dataframe(nested_list, [a, b, c]) a b c 0 [1, 1] 2 3 1 [7, 7] 8 9