Calculer le décalage temporel en jours - partie 1
Calculer le décalage temporel pour chaque transaction vous permet de présenter les indicateurs de chaque cohorte de manière comparable.
Nous allons d’abord créer 6 variables qui capturent les valeurs entières des années, mois et jours pour la date de facture (Invoice) et la date de cohorte (Cohort) à l’aide de la fonction get_date_int() déjà définie pour vous :
def get_date_int(df, column):
year = df[column].dt.year
month = df[column].dt.month
day = df[column].dt.day
return year, month, day
Les données online ont été chargées. Vous pouvez afficher son en-tête dans la console en appelant online.head().
Cet exercice fait partie du cours
Customer Segmentation in Python
Instructions
- Créez les objets
invoice_year,invoice_month,invoice_dayen appelant la fonctionget_date_intsur la colonneInvoiceDay. - Créez les objets
cohort_year,cohort_month,cohort_dayen appelant la fonctionget_date_intsur la colonneCohortDay.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Get the integers for date parts from the `InvoiceDay` column
____, ____, ____ = get_date_int(____, ____)
# Get the integers for date parts from the `CohortDay` column
____, ____, ____ = get_date_int(____, ____)