SQL+Tableau化妆品数据分析

一、项目介绍

本项目通过对化妆品10月、11月、12月、1月、2月的用户行为数据的探索,通过SQL数据处理以及tableau可视化,整个项目分为项目目的的确定、数据的预处理、对数据的分析和项目总结这五个部分。

二、项目流程

项目目的

从结果指标出发确定目标,通过过程指标定位问题,提出合理建议

数据来源

数据来源与和鲸社区,包含一个大型多品类在线商店5个月的用户行为数据,由Open CDP项目收集。文件中的每一行代表一个事件。所有事件都与产品和用户有关。共计9个字段。

数据预处理

因为单个月份的数据量高达300万以上,共计千万级数据集,产生较大的时间成本和内存成本,所以不将数据合并,对其分表查询,以下预处理对五个表都进行同样操作

缺失值处理

 对于dec表,分别对各个字段缺失值查取,得到结果为brand、category和user_session存在缺失值,因为后续操作用不到category和user_session,故将其过滤,而对于brand填充为'未知'

#缺失值处理
select event_time FROM dec_2019 where   event_time is null;
select event_type FROM dec_2019 where   event_type is null;
select product_id FROM dec_2019 where   product_id is null;
select category_id FROM dec_2019 where   category_id is null;
-- 缺失标记
select category_code FROM dec_2019 where   category_code is null;
-- 缺失标记
select brand FROM dec_2019 where   brand is null;
select price FROM dec_2019 where   price is null;
select user_id FROM dec_2019 where   user_id is null;
-- 缺失标记
select user_session FROM dec_2019_1 where   user_session is null;
select product_id FROM dec_2019_1 where   brand is null;
##dec_2019
-- 缺失值替换未知
UPDATE dec_2019
SET brand='未知'
where brand is NULL;

异常值处理

通过对price列探索发现存在负值,故将price列存在负值的数据删除

DELETE FROM dec_2019  where  price<0;

重复值处理

对单列重复值查询,发现存在重复值,采用distinct过滤

select DISTINCT a.event_time,a.event_type,a.product_id,a.category_id,a.brand,a.price,a.user_id from  dec_2019

添加时间维度

对于event_time列,在将数据导入时因为格式为2019-12-01 00:00:00 UTC,博主通过Navicat直接导入存在将event_time认定为null,输出1900-01-20 00:00:00,所以博主将event_time的数据类型定义为字符串,后续再将其转化为datetime,新建一个处理完的数据表,过滤不需要的字段

CREATE TABLE dec_2019_fin as 
select  DATE_FORMAT(left(a.event_time,10) ,'%Y-%m-%d') as time,
				year(left(a.event_time,10)) as year,
				MONTH(left(a.event_time,10)) as month,
				WEEK(left(a.event_time,10),1) as week,
				a.event_type,
				a.product_id,
				a.category_id,
				a.brand,
				a.price,
				a.user_id 
from  
(select DISTINCT event_time,event_type,product_id,category_id,brand,price,user_id from  dec_2019) a

可视化分析

对销售量和订单量汇总,并将其可视化,可以看到12月出现了明显下降趋势,将月份拆分,对11月和12月数据观察。

SELECT month as '月份',sum(price) as '销售额',count(1) as '订单量' FROM dec_2019_fin WHERE event_type = 'purchase' GROUP BY month
UNION ALL
SELECT month as '月份',sum(pr
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
>