def merge_features_by_rank(self, level: str, **kwargs: Any) -> Optional[Mapper]:
    'Merge features by taxonomic rank/level.\n\n        Parameters\n        ----------\n        level\n            Taxonomic rank/level to use for merging.\n        kwargs\n            Compatibility\n        '
    ret = {}
    if (not isinstance(level, str)):
        raise TypeError('`rank` must have str type.')
    if (level in self.__avail_ranks):
        target_ranks = get_rank_upto(self.avail_ranks, level, True)
        if target_ranks:
            tmp_lineages = generate_lineages_from_taxa(self.__internal_taxonomy, False, target_ranks, False)
            groups = tmp_lineages.groupby(tmp_lineages)
            if (len(groups.groups) > 1):
                tmp_feature_lineage = []
                tmp_groups = []
                group_indices = list(range(len(groups.groups)))
                for (lineage, feature_ids) in groups.groups.items():
                    tmp_feature_lineage.append(lineage)
                    tmp_groups.append(list(feature_ids))
                self.__init_internal_taxonomy(pd.Series(data=tmp_feature_lineage, index=group_indices))
                ret = dict(zip(group_indices, tmp_groups))
    else:
        raise ValueError('Invalid rank are provided.')
    return self._merge_features_by_map(ret, True, **kwargs)
Merge features by taxonomic rank/level.

Parameters
----------
level
    Taxonomic rank/level to use for merging.
kwargs
    Compatibility
def merge_features_by_rank(self, level: str, **kwargs: Any) -> Optional[Mapper]:
    'Merge features by taxonomic rank/level.\n\n        Parameters\n        ----------\n        level\n            Taxonomic rank/level to use for merging.\n        kwargs\n            Compatibility\n        '
    ret = {}
    if (not isinstance(level, str)):
        raise TypeError('`rank` must have str type.')
    if (level in self.__avail_ranks):
        target_ranks = get_rank_upto(self.avail_ranks, level, True)
        if target_ranks:
            tmp_lineages = generate_lineages_from_taxa(self.__internal_taxonomy, False, target_ranks, False)
            groups = tmp_lineages.groupby(tmp_lineages)
            if (len(groups.groups) > 1):
                tmp_feature_lineage = []
                tmp_groups = []
                group_indices = list(range(len(groups.groups)))
                for (lineage, feature_ids) in groups.groups.items():
                    tmp_feature_lineage.append(lineage)
                    tmp_groups.append(list(feature_ids))
                self.__init_internal_taxonomy(pd.Series(data=tmp_feature_lineage, index=group_indices))
                ret = dict(zip(group_indices, tmp_groups))
    else:
        raise ValueError('Invalid rank are provided.')
    return self._merge_features_by_map(ret, True, **kwargs)