get a group of columns from multi-index columns DataFrame Parameters ---------- df : pd.DataFrame with multi of columns. group : str the name of the feature group, i.e. the first level value of the group index.
(df: pd.DataFrame, group: Union[Text, None])
| 16 | |
| 17 | |
| 18 | def get_group_columns(df: pd.DataFrame, group: Union[Text, None]): |
| 19 | """ |
| 20 | get a group of columns from multi-index columns DataFrame |
| 21 | |
| 22 | Parameters |
| 23 | ---------- |
| 24 | df : pd.DataFrame |
| 25 | with multi of columns. |
| 26 | group : str |
| 27 | the name of the feature group, i.e. the first level value of the group index. |
| 28 | """ |
| 29 | if group is None: |
| 30 | return df.columns |
| 31 | else: |
| 32 | return df.columns[df.columns.get_loc(group)] |
| 33 | |
| 34 | |
| 35 | class Processor(Serializable): |