दिनों में समय का ऑफ़सेट निकालें - भाग 1
हर ट्रांज़ैक्शन के लिए time offset निकालने से आप हर cohort के मेट्रिक्स को तुलनीय तरीके से रिपोर्ट कर सकते हैं.
सबसे पहले, हम 6 वैरिएबल बनाएँगे जो Invoice और Cohort Date के लिए years, months और days का integer मान कैप्चर करें. इसके लिए पहले से परिभाषित get_date_int() फंक्शन का उपयोग कीजिए:
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
online डेटा लोड किया जा चुका है. आप online.head() कॉल करके इसका हैडर कंसोल पर प्रिंट कर सकते हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Customer Segmentation
अभ्यास निर्देश
InvoiceDayकॉलम परget_date_intफंक्शन कॉल करकेinvoice_year,invoice_month,invoice_dayऑब्जेक्ट बनाएँ.CohortDayकॉलम परget_date_intफंक्शन कॉल करकेcohort_year,cohort_month,cohort_dayऑब्जेक्ट बनाएँ.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# 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(____, ____)