(Adventure项目)自行车业务数据分析报告(四)

(Adventure项目)自行车业务数据分析报告(四)

项目背景
  • Adventure Works Cycles是Adventure Works样本数据库所虚构的公司,这是一家大型跨国制造公司。该公司生产和销售自行车到北美,欧洲和亚洲的商业市场。虽然其基地业务位于华盛顿州博塞尔,拥有290名员工,但几个区域销售团队遍布整个市场。

2019年11月自行车业务分析报告

目录:

  • 一、自行车整体销售表现
  • 二、2019年11月自行车地域销售表现
  • 三、2019年11月自行车产品销售表现
  • 四、用户行为分析
  • 五、2019年11月热品销售分析

本文主要介绍第四部分:用户行为分析,其他章节可访问本专栏Adventure自行车项目,建议订阅收藏

四、用户行为分析

这里我们需要使用订单明细表:ods_sales_orders,ods_customer用户表

#读取数据库客户信息表
engine = sqlalchemy.create_engine('mysql://id:*******@localhost:3306/db?charset=gbk')
df_CUSTOMER = pd.read_sql_query("select customer_key,birth_date,gender,marital_status from ods_customer where create_date < '2019-12-1'",con = engine)
df_CUSTOMER.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1063039 entries, 0 to 1063038
Data columns (total 4 columns):
customer_key      1063039 non-null int64
birth_date        1063039 non-null object
gender            1063039 non-null object
marital_status    1063039 non-null object
dtypes: int64(1), object(3)
memory usage: 32.4+ MB
#读取数据库销售订单表
engine = sqlalchemy.create_engine('mysql://id:**********@localhost:3306/db?charset=gbk')
df_sales_orders_11 = pd.read_sql_query("select *  from ods_sales_orders where create_date>='2019-11-1' and   create_date<'2019-12-1'",con = engine)
df_sales_orders_11.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 13286 entries, 0 to 13285
Data columns (total 8 columns):
sales_order_key         13286 non-null int64
create_date             13286 non-null object
customer_key            13286 non-null object
product_key             13286 non-null object
english_product_name    13286 non-null object
cpzl_zw                 13286 non-null object
cplb_zw                 13286 non-null object
unit_price              13286 non-null float64
dtypes: float64(1), int64(1), object(6)
memory usage: 830.5+ KB
  • 销售订单表中仅客户编号,无客户年龄性别等信息,需要将销售订单表和客户信息表合并
df_sales_orders_11.customer_key=df_sales_orders_11.customer_key.astype(int)
#pd.merge
sales_customer_order_11=pd.merge(df_sales_orders_11,df_CUSTOMER,on='customer_key',how='inner')
sales_customer_order_11.head()
sales_order_key create_date customer_key product_key english_product_name cpzl_zw cplb_zw unit_price birth_date gender marital_status
0 130506 2019-11-01 203511 530 Touring Tire Tube 轮胎和内胎 配件 4.990000 1971-03-11 M S
1 130507 2019-11-01 525075 222 Sport-100 Helmet 头盔 配件 34.990000 1982-12-17 M M
2 130508 2019-11-01 756867 537 HL Mountain Tire 轮胎和内胎 配件 35.000000 1980-02-22 F M
3 130509 2019-11-01 742098 222 Sport-100 Helmet 头盔 配件 34.990000 1981-09-06 M M
4 130510 2019-11-01 314788 581 Road-350-W Yellow 公路自行车 自行车 1700.990000 1962-06-21 F M

4.1、用户年龄分析

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值