自行车业务分析 3.1 3.2

三、2019年11月自行车产品销售表现

3.1、数据源 dw_customer_order

#查看数据源

gather_customer_order.head(3)

3.2、细分市场销量表现

作业 3.2.1、gather_customer_order表利用groupby聚合月份,求每个月自行车的销售数量,赋值给变量gather_customer_order_group_month

#求每个月自行车累计销售数量

gather_customer_order_group_month = gather_customer_order.groupby('create_year_month').agg({'order_num':'sum'},axis=0).reset_index()

gather_customer_order_group_month.head()

作业 3.2.2、利用pd.merge模块合并自行车销售信息表(gather_customer_order)+自行车每月累计销售数量表(gather_customer_order_group_month)赋值变量给order_num_proportion

order_num_proportion = pd.merge(gather_customer_order,gather_customer_order_group_month,on='create_year_month',how='left')

作业 3.2.3、计算自行车销量/自行车每月销量占比,计算结果形成新的列'order_proportion'

order_num_proportion['order_proportion']=order_num_proportion['order_num_x']/order_num_proportion['order_num_y']

作业 3.2.4、重命名自行车每月销售量order_num_y为sum_month_order

#重命名sum_month_order:自行车每月销售量

order_num_proportion = order_num_proportion.rename(columns={'order_num_y':'sum_month_order'})

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容