Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Multi-Dimensional Cohort Segmentation | s1
Cohort Analysis with Python
Sektion 1. Kapitel 4
single

single

Multi-Dimensional Cohort Segmentation

Stryg for at vise menuen

Multi-dimensional cohort segmentation lets you group users by more than one attribute, such as both the month they signed up and the channel through which they were acquired. While traditional cohort analysis might focus on a single factor - like signup date - multi-dimensional segmentation helps you answer more complex questions. For example, you could see if users from a specific marketing campaign in a certain month behave differently than those from another channel or region. This approach is valuable for businesses because it highlights patterns and trends that are not visible when analyzing only one dimension. By segmenting cohorts using multiple factors, you can tailor marketing strategies, improve customer retention, and allocate resources more effectively.

12345678910111213141516171819202122
import pandas as pd # Sample data data = { "user_id": [1, 2, 3, 4, 5, 6], "signup_date": [ "2023-01-15", "2023-01-15", "2023-02-10", "2023-02-15", "2023-01-25", "2023-02-18" ], "acquisition_channel": [ "Email", "Email", "Social", "Ad", "Ad", "Social" ] } df = pd.DataFrame(data) df["signup_month"] = pd.to_datetime(df["signup_date"]).dt.to_period("M") # Multi-dimensional cohort segmentation by signup_month and acquisition_channel cohorts = df.groupby(["signup_month", "acquisition_channel"])["user_id"].nunique().reset_index() cohorts = cohorts.rename(columns={"user_id": "num_users"}) print(cohorts)

By segmenting cohorts using both signup_month and acquisition_channel, you can spot hidden trends that single-dimensional analysis might miss. For instance, you might find that users acquired via "Email" in January are more engaged or have higher retention than those acquired via "Ad" in the same month. This level of detail allows you to make data-driven decisions about where to invest your marketing budget, how to personalize onboarding experiences, and which channels yield the most valuable customers. Multi-dimensional segmentation is a powerful tool for uncovering insights that drive business growth.

Opgave

Swipe to start coding

  • Group users by both signup_month and acquisition_channel using the provided DataFrame df.
  • For each cohort (combination of signup_month and acquisition_channel), count the number of unique user_ids.
  • Store the result in a new DataFrame named cohorts with columns: signup_month, acquisition_channel, and num_users.
  • Do not print the result. Only define the DataFrame as specified.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 4
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

some-alt