def combine_min_categories(self, X):
    'Combine small categories into a single category.'
    for (col, mapper) in self.mapping.items():
        if (self._normalize[col] and isinstance(self._min_group_size[col], int)):
            self._min_group_size[col] = (self._min_group_size[col] / X.shape[0])
        elif ((not self._normalize) and isinstance(self._min_group_size[col], float)):
            self._min_group_size[col] = (self._min_group_size[col] * X.shape[0])
        if (self._combine_min_nan_groups[col] is True):
            min_groups_idx = (mapper < self._min_group_size[col])
        elif (self._combine_min_nan_groups[col] == 'force'):
            min_groups_idx = ((mapper < self._min_group_size[col]) | mapper.index.isna())
        else:
            min_groups_idx = ((mapper < self._min_group_size[col]) & (~ mapper.index.isna()))
        min_groups_sum = mapper.loc[min_groups_idx].sum()
        if ((min_groups_sum > 0) and (min_groups_idx.sum() > 1)):
            if isinstance(self._min_group_name[col], str):
                min_group_mapper_name = self._min_group_name
            else:
                min_group_mapper_name = '_'.join([str(idx) for idx in mapper.loc[min_groups_idx].index.astype(str).sort_values()])
            self._min_group_categories[col] = {cat: min_group_mapper_name for cat in mapper.loc[min_groups_idx].index.tolist()}
            if (not min_groups_idx.all()):
                mapper = mapper.loc[(~ min_groups_idx)]
                if mapper.index.is_categorical():
                    mapper.index = mapper.index.add_categories(min_group_mapper_name)
                mapper[min_group_mapper_name] = min_groups_sum
        self.mapping[col] = mapper
Combine small categories into a single category.
def combine_min_categories(self, X):
    
    for (col, mapper) in self.mapping.items():
        if (self._normalize[col] and isinstance(self._min_group_size[col], int)):
            self._min_group_size[col] = (self._min_group_size[col] / X.shape[0])
        elif ((not self._normalize) and isinstance(self._min_group_size[col], float)):
            self._min_group_size[col] = (self._min_group_size[col] * X.shape[0])
        if (self._combine_min_nan_groups[col] is True):
            min_groups_idx = (mapper < self._min_group_size[col])
        elif (self._combine_min_nan_groups[col] == 'force'):
            min_groups_idx = ((mapper < self._min_group_size[col]) | mapper.index.isna())
        else:
            min_groups_idx = ((mapper < self._min_group_size[col]) & (~ mapper.index.isna()))
        min_groups_sum = mapper.loc[min_groups_idx].sum()
        if ((min_groups_sum > 0) and (min_groups_idx.sum() > 1)):
            if isinstance(self._min_group_name[col], str):
                min_group_mapper_name = self._min_group_name
            else:
                min_group_mapper_name = '_'.join([str(idx) for idx in mapper.loc[min_groups_idx].index.astype(str).sort_values()])
            self._min_group_categories[col] = {cat: min_group_mapper_name for cat in mapper.loc[min_groups_idx].index.tolist()}
            if (not min_groups_idx.all()):
                mapper = mapper.loc[(~ min_groups_idx)]
                if mapper.index.is_categorical():
                    mapper.index = mapper.index.add_categories(min_group_mapper_name)
                mapper[min_group_mapper_name] = min_groups_sum
        self.mapping[col] = mapper