alifestd_coarsen_taxa_asexual

alifestd_coarsen_taxa_asexual(phylogeny_df: DataFrame, mutate: bool = False, *, agg: Dict[str, str] | None = None, by: str | Sequence[str]) DataFrame

Condense consecutive phylogeny nodes sharing identical trait values, according to values in by column(s).

The manner in which consecutive nodes with identical traits are condensed may be fine-tuned on a column-by-column basis through the optional agg kwarg, a dict mapping column names to a Pandas GroupBy aggregation operation (e.g., “first”, “min”, “max”, etc.).

Input dataframe is not mutated by this operation unless mutate set True. If mutate set True, operation does not occur in place; still use return value to get transformed phylogeny dataframe.

Dataframe reindexing (e.g., df.index) may be applied.

See Also

alifestd_coarsen_taxa_asexual_make_agg :

Helper function to generate default agg dict, which may be customized before being passed to alifestd_coarsen_taxa_asexual.