alifestd_mark_num_preceding_leaves_asexual
- alifestd_mark_num_preceding_leaves_asexual(phylogeny_df: DataFrame, mutate: bool = False, *, mark_as: str = 'num_preceding_leaves') DataFrame
Add column num_preceding_leaves with count of all leaves occurring before the present node in an inorder traversal.
The output column name can be changed via the
mark_asparameter.For internal nodes, the number of leaf nodes prior to the traversal of first (i.e., leftmost) descendant is marked.
A topological sort will be applied if phylogeny_df is not topologically sorted. Dataframe reindexing (e.g., df.index) may be applied.
Must be a strictly bifurcating tree.
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.