import pandas as pd

def get_variants(workflow):
    variants = workflow.groupby('case')['activity'].apply(tuple).reset_index()
    return variants

def variant_counts(variants):
    variants_count = variants.groupby('activity').count().reset_index()
    return variants_count.sort_values('case', ascending=False)