https://github.com/HAMJiyoung/Google-sample-data-cohort-analysis
2016년 8월부터 2017년 7월까지의 Google merchandise store 데이터를 사용하였습니다.
구글 빅쿼리를 파이썬과 연결하여 추출 후 전처리를 진행하였습니다.
코드
query_string = """
select date,
fullVisitorId as user_id,
visitId as session_id,
case h.eCommerceAction.action_type
when '2' then 'product view'
when '3' then 'add to cart'
when '5' then 'purchase started'
when '6' then 'purchase completed'
end as action,
p.v2ProductCategory as category,
p.v2ProductName as name,
p.productRevenue as item_revenue,
h.transaction.transactionRevenue as total_revenue
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*`
LEFT JOIN UNNEST(hits) as h
LEFT JOIN UNNEST(h.product) as p
where _TABLE_SUFFIX BETWEEN '20160801' AND '20170731'
and h.eCommerceAction.action_type in ('2', '3', '5', '6')
order by date ;
"""
df = client.query(query_string).to_dataframe()
df.head()
column
총 약 1,733,145 달러
월별
일별
일부 날짜에 매출이 편중되어 있습니다.
일자별 기록을 보니 2017년 4월 5일, 18일이 전체 중 가장 높은 매출입니다. 이 이틀이 4월 매출의 원인으로 보입니다.
매출이 가장 높은 달(약 222,894)과 낮은 달(약 106,320)의 차이는 매출이 가장 낮은 달의 약 1.1배입니다.