rename_keys#
- gaitmap_challenges.results.rename_keys(in_dict: Dict[Hashable, Any], mapping_or_callable: Union[Dict[Hashable, Hashable], Callable[[Hashable], Hashable]], missing: Literal['ignore', 'raise', 'remove'] = 'raise')[source]#
Rename the keys of a dictionary.
- Parameters:
- in_dict
The dictionary to rename.
- mapping_or_callable
Either a dictionary mapping the old keys to the new keys or a callable that takes the old key as input and returns the new key.
- missing
What to do if a no new key can be found for a key in the dictionary. If “ignore”, the old key is kept with its old name. If “raise”, an exception is raised. If “remove”, the key is removed from the dictionary.
To trigger the “missing” case when using a callable, the callable must raise an exception.
- Returns:
- renamed_dict
The renamed dictionary.