baybe.utils.augmentation.df_apply_permutation_augmentation

baybe.utils.augmentation.df_apply_permutation_augmentation(df: DataFrame, column_groups: Sequence[Sequence[str]])[source]

Augment a dataframe if permutation invariant columns are present.

Parameters:
  • df (DataFrame) – The dataframe that should be augmented.

  • column_groups (Sequence[Sequence[str]]) – Sequences of permutation invariant columns. The n’th column in each group will be permuted together with each n’th column in the other groups.

Return type:

DataFrame

Returns:

The augmented dataframe containing the original one. Augmented row indices are identical with the index of their original row.

Raises:
  • ValueError – If less than two column groups are given.

  • ValueError – If a column group is empty.

  • ValueError – If the column groups have differing amounts of entries.

Examples

>>> df = pd.DataFrame({'A1':[1,2],'A2':[3,4], 'B1': [5, 6], 'B2': [7, 8]})
>>> df
   A1  A2  B1  B2
0   1   3   5   7
1   2   4   6   8
>>> column_groups = [['A1'], ['A2']]
>>> dfa = df_apply_permutation_augmentation(df, column_groups)
>>> dfa
   A1  A2  B1  B2
0   1   3   5   7
0   3   1   5   7
1   2   4   6   8
1   4   2   6   8
>>> column_groups = [['A1', 'B1'], ['A2', 'B2']]
>>> dfa = df_apply_permutation_augmentation(df, column_groups)
>>> dfa
   A1  A2  B1  B2
0   1   3   5   7
0   3   1   7   5
1   2   4   6   8
1   4   2   8   6