mlnext.utils.convert_sequences¶
- mlnext.utils.convert_sequences(mapping: Dict[str, Any], ignore_sequence_types: Tuple[Type, ...] = ()) Dict[str, Any][source]¶
Converts sequences in
mappingto a dict by the index.- Parameters:
mapping (T.Dict[str, T.Any]) – Input dict.
ignore_sequence_types – Sequence types to leave as-is.
- Returns:
Returns the new dict.
- Return type:
T.Dict[str, T.Any]
Example
>>> mapping = {'a': {'b':[{'c': 0, 'd': {'e': 1}},'f']}} >>> convert_sequence(mapping) {'a': {'b': {'0': {'c': 0, 'd': {'e': 1}}, '1': 'f'}}}