riptable.Utils.conversion_utils
Functions
|
Converts a dictionary of Datasets to a single Dataset appending the dictionary |
|
|
|
Converts a dict of Datasets to a list, appending the keyname as a new field key_field_name. |
|
Converts arr 2D ndarray and column names to arr dict (is ordered) of ndarray's |
|
|
|
- riptable.Utils.conversion_utils.append_dataset_dict(ds_dict, key_field_name)
Converts a dictionary of Datasets to a single Dataset appending the dictionary keys as key_field_name to distinguish them. NB: This modifies the original Datasets!
- TODO: add support for harmonizing fields, e.g.,
fill missing values and deal with differing types
- Parameters:
ds_dict – dictionary of Datasets. Keys MUST be ascii strings (or bytes)!
key_field_name – New column to add to each to which Dataset will be assigned the constant value of the key.
- Returns:
New dataset.
- riptable.Utils.conversion_utils.dataset_as_matrix(ds, save_metadata=True, column_data={})
- riptable.Utils.conversion_utils.dset_dict_to_list(ds_dict, key_field_name, allow_overwrite=False)
Converts a dict of Datasets to a list, appending the keyname as a new field key_field_name. NB: This modifies the Datasets!
TODO: allow option of inplace or copy
- Parameters:
ds_dict – dictionary of Datasets. Keys MUST be ascii strings (or bytes)!
key_field_name – New column to add to each to which Dataset will be assigned the constant value of the key.
allow_overwrite – Unless set to True the key_field_name may not exist in any of the input Datasets.
- Returns:
list of original Datasets _modified_.
- riptable.Utils.conversion_utils.numpy2d_to_dict(arr, columns)
Converts arr 2D ndarray and column names to arr dict (is ordered) of ndarray’s suitable for the Dataset constructor:
- Parameters:
arr – numpy NxM ndarray
columns – list of M column names
- Returns:
dictionary suitable for rt.Dataset constructor
Example: import numpy as np import riptable as rt from rt.Utils.conversion_utils import numpy2d_to_dict
arr = np.array([[1, 2, 3], [4, 5, 6]]) columns = [‘c1’, ‘c2’, ‘c3’] dset = rt.Dataset(numpy2d_to_dict(arr, columns)) print(dset)
- riptable.Utils.conversion_utils.numpy_array_to_dataset(inarray, columns=None)
- riptable.Utils.conversion_utils.numpy_array_to_dict(inarray, columns=None)