aixd.data.utils_data.reformat_dataframeflat_to_dict

aixd.data.utils_data.reformat_dataframeflat_to_dict(dataframe: pd.DataFrame, dataobjects: List[DataObject], listwrap: bool = False) Dict[source]

Reformats data stored in a dataframe to a dictionary collated accordingly to the provided list of data objects. In the dataframe, the data is “flattened”, i.e. the cells contain single values and for data objects with dim>1 are stored in columns named as in DataObject.columns_df. In the resulting dictionary, the keys correspond to the original object names and the values store a list of values for individual samples. To access a particular value: dict[dataobject_name_as_key][nth_sample][ith_dimension].

Note: Any columns in the dataframe that cannot be associated with any data object will be ignored. Any data objects with no corresponding column in the dataframe will be ignored.

Parameters:
  • dataframe (pd.DataFrame) – A dataframe with “flattened” data.

  • dataobjects (List[DataObject]) – A list of data objects from the dataset.

  • listwrap (bool, optional, default=False) – If True, 1-dimensional values will be put into a 1-item list (e.g., 3.14 -> [3.14]).

Returns:

Dict – A dictionary with keys corresponding to the original data object names and collated according to their dimensionality.