cohort analysis with Python