CLN refactor with _apply_to_column_groupbys