일 단위 시간 오프셋 계산 - 1단계
각 거래의 시간 오프셋을 계산하면 각 코호트에 대해 지표를 서로 비교 가능한 방식으로 보고할 수 있어요.
먼저, 이미 정의되어 있는 get_date_int() 함수를 사용해 Invoice 날짜와 Cohort 날짜의 연도, 월, 일을 정수로 추출하는 6개의 변수를 만들겠습니다:
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을 활용한 고객 세분화
연습 안내
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(____, ____)