Skip to main content

system.kanoa.utilities.convertDatasetToDict

Description

Given the name of a key column and value column, this function converts a dataset into a dictionary of key-value pairs. If valueCol is None, all data columns will be returned as values for each key. (kanoaCore).

Syntax

convertDatasetToDict(data, keyCol, valueCol)
  • Parameters
      data (Dataset) - The input dataset.
      keyCol (String or list of Strings) - The name of the column to be used as a key or list of columns, e.g., 'configName' or ['configName', 'configId'].
      valueCol (String) - The name of the value column, e.g., 'configValue'.
  • Returns
      dictionary - A dictionary of key-value pairs.
  • Code Examples

    python
    data_dict = system.kanoa.utilities.convertDatasetToDict(data, 'configName', 'configValue')