hpcflow.sdk.core.utils.group_by_dict_key_values#

hpcflow.sdk.core.utils.group_by_dict_key_values(lst: list[dict[T, T2]], key: T) list[list[dict[T, T2]]]#
hpcflow.sdk.core.utils.group_by_dict_key_values(lst: list[TD], key: str) list[list[TD]]

Group a list of dicts according to specified equivalent key-values.

Parameters:
  • lst (list of dict) – The list of dicts to group together.

  • key (key value) – Dicts that have identical values for all of these keys will be grouped together into a sub-list.

Returns:

grouped

Return type:

list of list of dict

Examples

>>> group_by_dict_key_values([{'a': 1}, {'a': 2}, {'a': 1}], 'a')
[[{'a': 1}, {'a': 1}], [{'a': 2}]]