自行车销售案例分析总结

本文是对某自行车制造公司2020年11月销售情况进行分析总结,为精细化运营提供数据支持。
本文目录:
一、 分析目的
二、分析过程
三、看板展示

一、分析目的

通过对整个公司的自行车销量持续监测和分析,掌握公司自行车销售状况、走势的变化,为客户制订、调整和检查销售策略,完善产品结构提供依据。

二、分析过程

分析过程导图如下:


image.png

具体分析如下:

2.1 自行车整体销售表现

  • 导入模块包
#导入模块
import pandas as pd
import numpy as np
import pymysql
#pymysql.install_as_MySQLdb()
from sqlalchemy import create_engine
  • 读取数据
sql='select * from dw_customer_order'
engine=create_engine('mysql+pymysql://frogdata05:Frogdata!1321@106.15.121.232:3306/datafrog05_adventure')
gather_customer_order=pd.read_sql(sql,con=engine)
gather_customer_order.head()
image.png
  • 查看数据源类型
gather_customer_order.info()
image.png
  • 增加月份字段
gather_customer_order['year_monrh']=gather_customer_order['create_date'].apply(lambda x:x.strftime('%Y-%m'))
gather_customer_order.head()
image.png
  • 筛选产品类型为自行车的数据
gather_customer_order=gather_customer_order.loc[gather_customer_order['cplb_zw']=='自行车']
gather_customer_order.head()
image.png
  • 整体销量表现:按月份分组聚合总订单量和总销售额
overall_sales_performance=gather_customer_order.groupby('year_month').agg({'order_num':'sum','sum_amount':'sum'}).\
sort_index(ascending=False).reset_index()
overall_sales_performance
image.png
  • ·计算订单量和销售金额环比
#计算订单量环比
order_num_diff=list(overall_sales_performance.order_num.diff()/overall_sales_performance.order_num/-1)
order_num_diff.pop(0) #删除列表的第一个元素
order_num_diff.append(0) #列表末尾增加元素0
order_num_diff
overall_sales_performance['order_num_diff']=order_num_diff
# 计算销售金额环比
sum_amount_diff=list(overall_sales_performance.sum_amount.diff()/overall_sales_performance.sum_amount/-1)
sum_amount_diff.pop(0) #删除列表的第一个元素
sum_amount_diff.append(0) #列表末尾增加元素0
sum_amount_diff
overall_sales_performance['sum_amount_diff']=sum_amount_diff
overall_sales_performance
image.png
  • 图表展示:


    image.png

2.2、2020年11月自行车地域销售表现

  • 数据清洗,筛选10月、11月自行车销售数据
gather_customer_order_10_11 = gather_customer_order[gather_customer_order['year_month'].isin(['2020-10','2020-11'])]
gather_customer_order_10_11
image.png
  • 2020年11月各区域销售量情况
  • 按区域、月份进行分组聚合
gather_customer_order_10_11_group=gather_customer_order_10_11.groupby(['chinese_territory','year_month']).agg({'order_num':sum,'sum_amount':sum}).reset_index()
gather_customer_order_10_11_group
image.png
  • 求各大区域10月、11月环比
#将区域存为列表
region=gather_customer_order_10_11_group['chinese_territory'].drop_duplicates(keep='first').tolist()
order_x = pd.Series([])
amount_x = pd.Series([])
for i in region:
    a=gather_customer_order_10_11_group.loc[gather_customer_order_10_11_group['chinese_territory']==i]['order_num'].pct_change().fillna(0)
    b=gather_customer_order_10_11_group.loc[gather_customer_order_10_11_group['chinese_territory']==i]['sum_amount'].pct_change().fillna(0)
    order_x=order_x.append(a)
    amount_x = amount_x.append(b)
gather_customer_order_10_11_group['order_diff']=order_x
gather_customer_order_10_11_group['amount_diff']=amount_x
gather_customer_order_10_11_group.head()
image.png
  • 求订单量TPO10城市的10、11月环比
#11月份销量数据
gather_customer_order_11=gather_customer_order_10_11[gather_customer_order_10_11['year_month']=='2020-11']
#11月份TOP10城市
gather_customer_order_city_head=gather_customer_order_11.groupby('chinese_city').order_num.sum().sort_values(ascending=False).reset_index().head(10)
#筛选10、11月TOP10销售数据
gather_customer_order_10_11_head=gather_customer_order_10_11[gather_customer_order_10_11['chinese_city'].isin(gather_customer_order_city_head['chinese_city'])]
#分组计算top10城市的订单量和订单金额
gather_customer_order_city_10_11=gather_customer_order_10_11_head.groupby(['chinese_city','year_month']).agg({'order_num':sum,'sum_amount':sum}).reset_index()
city_list=gather_customer_order_city_10_11['chinese_city'].unique().tolist()
order_top_x=pd.Series([])
amount_top_x=pd.Series([])
for i in city_list:
    a=gather_customer_order_city_10_11.loc[gather_customer_order_city_10_11['chinese_city']==i]['order_num'].pct_change().fillna(0)
    b=gather_customer_order_city_10_11.loc[gather_customer_order_city_10_11['chinese_city']==i]['sum_amount'].pct_change().fillna(0)
    order_top_x=order_top_x.append(a)
    amount_top_x=amount_top_x.append(b)
gather_customer_order_city_10_11['order_diff']=order_top_x
gather_customer_order_city_10_11['sum_diff']=amount_top_x
gather_customer_order_city_10_11.head()
image.png

图表展示:


image.png

2.3、2020年11月自行车产品销售表现

  • 细分市场销量表现
    • 日销售量占月销售量比例
#细分市场销售表现
gather_customer_order_group_month=gather_customer_order.groupby('year_month').order_num.sum().reset_index()
gather_customer_order_group_month
order_num_proportion=pd.merge(gather_customer_order,gather_customer_order_group_month,on='year_month')
#计算自行车日销售占月销售比
order_num_proportion['order_proportion']=order_num_proportion['order_num_x']/order_num_proportion['order_num_y']
order_num_proportion=order_num_proportion.rename(columns={'order_num_y':'sum_month_order'})
order_num_proportion.head()
image.png
  • 公路/山地/旅行自行车细分市场销售表现
    • 公路自行车各型号产品与月累计销量比值
#公路/山地/旅行自行车销售表现
#公路自行车筛选
gather_customer_order_road=gather_customer_order[gather_customer_order['cpzl_zw']=='公路自行车']
#公路自行车产品型号月销量
gather_customer_order_road_month=gather_customer_order_road.groupby(['year_month','product_name']).order_num.sum().reset_index()
#每个月公路自行车累计销量
gather_customer_order_road_month_sum=gather_customer_order_road_month.groupby('year_month').order_num.sum().reset_index()
#各型号公路自行车日销售量占月销售量比值
gather_customer_order_road_num_proportion=pd.merge(gather_customer_order_road_month,gather_customer_order_road_month_sum,on='year_month')
gather_customer_order_road_num_proportion=gather_customer_order_road_num_proportion.rename(columns={'order_num_x':'order_num','order_num_y':'order_num_sum'})
gather_customer_order_road_num_proportion['order_proportion']=gather_customer_order_road_num_proportion['order_num']/gather_customer_order_road_num_proportion['order_num_sum']
gather_customer_order_road_num_proportion['cpzl_zw']='公路自行车'
gather_customer_order_road_num_proportion.head()
image.png
  • 相同的步骤,得到每月各型号山地自行车销售量占月总销售量比值
#山地自行车筛选
gather_customer_order_mountain=gather_customer_order[gather_customer_order['cpzl_zw']=='山地自行车']
#山地自行车产品型号月销量
gather_customer_order_mountain_month=gather_customer_order_mountain.groupby(['year_month','product_name']).order_num.sum().reset_index()
#每个月山地自行车累计销量
gather_customer_order_mountain_month_sum=gather_customer_order_mountain_month.groupby('year_month').order_num.sum().reset_index()
#各型号山地自行车日销售量占月销售量比值
gather_customer_order_mountain_num_proportion=pd.merge(gather_customer_order_mountain_month,gather_customer_order_mountain_month_sum,on='year_month')
gather_customer_order_mountain_num_proportion=gather_customer_order_mountain_num_proportion.rename(columns={'order_num_x':'order_num','order_num_y':'order_num_sum'})
gather_customer_order_mountain_num_proportion['order_proportion']=gather_customer_order_mountain_num_proportion['order_num']/gather_customer_order_mountain_num_proportion['order_num_sum']
gather_customer_order_mountain_num_proportion['cpzl_zw']='山地自行车'
gather_customer_order_mountain_num_proportion.head()
image.png
  • 类似的步骤得到旅游自行车的占比情况
#旅行自行车筛选
gather_customer_order_tour=gather_customer_order[gather_customer_order['cpzl_zw']=='旅游自行车']
#旅行自行车产品型号月销量
gather_customer_order_tour_month=gather_customer_order_tour.groupby(['year_month','product_name']).order_num.sum().reset_index()
#每个月旅行自行车累计销量
gather_customer_order_tour_month_sum=gather_customer_order_tour_month.groupby('year_month').order_num.sum().reset_index()
#各型号旅行自行车日销售量占月销售量比值
gather_customer_order_tour_num_proportion=pd.merge(gather_customer_order_tour_month,gather_customer_order_tour_month_sum,on='year_month')
gather_customer_order_tour_num_proportion=gather_customer_order_tour_num_proportion.rename(columns={'order_num_x':'order_num','order_num_y':'order_num_sum'})
gather_customer_order_tour_num_proportion['order_proportion']=gather_customer_order_tour_num_proportion['order_num']/gather_customer_order_tour_num_proportion['order_num_sum']
gather_customer_order_tour_num_proportion['cpzl_zw']='旅游自行车'
gather_customer_order_tour_num_proportion.head()
image.png
  • 将以上公路/山地/旅行自行车信息合并
gather_customer_order_num_proportion=pd.concat([gather_customer_order_road_num_proportion,gather_customer_order_mountain_num_proportion,gather_customer_order_tour_num_proportion])
gather_customer_order_num_proportion.head()
image.png
  • 计算2020年11月自行车销量环比
gather_customer_order_num_proportion_10_11=\
gather_customer_order_num_proportion[gather_customer_order_num_proportion['year_month'].isin(['2020-10','2020-11'])]
#排序
gather_customer_order_num_proportion_10_11=gather_customer_order_num_proportion_10_11.sort_values(['product_name','year_month'])
#计算自行车销售数量环比
gather_customer_order_num_proportion_10_11
product_name  = list(gather_customer_order_num_proportion_10_11.product_name.drop_duplicates())
order_top_x=pd.Series([])
for i in product_name:
    a=gather_customer_order_num_proportion_10_11.loc[gather_customer_order_num_proportion_10_11['product_name']==i]['order_num'].pct_change().fillna(0)
    order_top_x=order_top_x.append(a)
gather_customer_order_num_proportion_10_11['order_diff']=order_top_x
gather_customer_order_num_proportion_11=gather_customer_order_num_proportion_10_11[gather_customer_order_num_proportion_10_11['year_month']=='2020-11']
gather_customer_order_num_proportion_11.head()
image.png
  • 计算2020年1-11月累计销量
#1-11月自行车数据
gather_customer_order_num_proportion_1_11=gather_customer_order_num_proportion[gather_customer_order_num_proportion['year_month'].\
isin(['2020-01','2020-02','2020-03','2020-04','2020-05','2020-06','2020-07','2020-08','2020-09','2020-10','2020-11'])]
gather_customer_order_num_1_11_sum=gather_customer_order_num_proportion_1_11.groupby('product_name').order_num.sum().reset_index()
gather_customer_order_num_1_11_sum=gather_customer_order_num_1_11_sum.rename(columns={'order_num':'sum_order_1_11'})
gather_customer_order_num_1_11_sum.head()
image.png
  • 2020年11月自行车产品销量、环比、累计销量
    累计销量在gather_customer_order_num_1_11_sum已计算好,11月自行车环比及销量占比在gather_customer_order_num_proportion_11已计算好,只需将两表关联起来。
gather_customer_order_num_proportion_11=pd.merge(gather_customer_order_num_proportion_11,gather_customer_order_num_1_11_sum,on='product_name')
gather_customer_order_num_proportion_11.head()
image.png

图表展示:


image.png

2.4、用户行为分析

  • 从数据库读取订单明细表
#读取数据库销售订单表
sql="select *  from ods_sales_orders where create_date>='2020-11-1' and  create_date<'2020-12-1'"
engine=create_engine('mysql+pymysql://frogdata001:Frogdata@144@106.12.180.221:3306/adventure_ods')
df_sales_orders_11=pd.read_sql(sql,con=engine)
df_sales_orders_11
image.png
  • 读取客户信息表
sql="select * from ods_customer"
engine=create_engine('mysql+pymysql://frogdata001:Frogdata@144@106.12.180.221:3306/adventure_ods')
df_customer=pd.read_sql(sql,con=engine)
df_customer.head()
image.png
  • 合并订单表和客户信息表
sales_customer_order_11=pd.merge(df_sales_orders_11,df_customer,on='customer_key',how='left')
sales_customer_order_11
image.png
  • 客户年龄分析
    • 获取用户出生年份作为新的一列
customer_birth_year = sales_customer_order_11['birth_date'].str.split('-',expand = True).rename(columns = {0:'birth_year'}).drop(labels = [1,2],axis = 1)
sales_customer_order_11 = pd.concat([sales_customer_order_11,customer_birth_year],axis = 1)
sales_customer_order_11.head(3)
image.png
  • 用户年龄分析
#修改出生年为int数据类型
sales_customer_order_11['birth_year'] = sales_customer_order_11['birth_year'].astype('int')
# 计算用户年龄
sales_customer_order_11['customer_age'] = 2020 - sales_customer_order_11['birth_year']
新增'age_level'分层区间列
sales_customer_order_11['age_level'] = pd.cut(sales_customer_order_11['customer_age'], [30,35,40,45,50,55,60,65], labels=["30-34","35-39","40-44","45-49","50-54","55-59","60-64"])
#筛选销售订单为自行车的订单信息
df_customer_order_bycle = sales_customer_order_11.loc[sales_customer_order_11['cplb_zw'] == '自行车']
# 计算年龄比率
df_customer_order_bycle['age_level_rate'] = 1 / len(df_customer_order_bycle)
#将年龄分为3个层次
df_customer_order_bycle.loc[(df_customer_order_bycle['customer_age'] <= 29),'age_level2'] = '<=29'
df_customer_order_bycle.loc[(df_customer_order_bycle['customer_age'] >= 30) & (df_customer_order_bycle['customer_age'] < 40),'age_level2'] = '30-39'
df_customer_order_bycle.loc[(df_customer_order_bycle['customer_age'] >= 40),'age_level2'] = '>=40'
df_customer_order_bycle.head(3)
image.png
  • 求每个年龄段的人数
# 求每个年龄段人数
age_level2_count = df_customer_order_bycle.groupby(by = 'age_level2').sales_order_key.count().reset_index()
age_level2_count
image.png
  • 用户性别分析
gender_count = df_customer_order_bycle.groupby(by = 'gender').cplb_zw.count().reset_index()
# 求每个年龄段人数
age_level2_count = df_customer_order_bycle.groupby(by = 'age_level2').sales_order_key.count().reset_index()
# 关联上 age_level2_count,也就是各年龄段的人数
df_customer_order_bycle = pd.merge(df_customer_order_bycle,age_level2_count,on = 'age_level2').rename(columns = {'sales_order_key_y':'age_level2_count'})
df_customer_order_bycle['age_level2_rate'] = 1/df_customer_order_bycle['age_level2_count']
# 关联上 gender_count,也就是各个性别的人数
df_customer_order_bycle = pd.merge(df_customer_order_bycle,gender_count,on = 'gender').rename(columns = {'cplb_zw_y':'gender_count'})
df_customer_order_bycle['gender_rate'] = 1/df_customer_order_bycle['gender_count']
df_customer_order_bycle.head()
image.png
  • 可视化图表分析:


    image.png

2.5、2020年11月热品销售分析

  • 11月产品销量TOP10产品、销量及环比
    前面计算,直接拿来用
#筛选11月数据
gather_customer_order_11 = gather_customer_order.loc[gather_customer_order['year_month'] == '2020-11']
customer_order_11_top10 = gather_customer_order_11.groupby(by = 'product_name').order_num.count().reset_index().\
                        sort_values(by = 'order_num',ascending = False).head(10)
customer_order_11_top10.head()
image.png
  • 销量前10的产品信息
#TOP10销量产品信息
list(customer_order_11_top10['product_name'])
image.png
  • 计算TOP10销量及环比
gather_customer_order_num_proportion_10_11.head()
customer_order_num_proportion_10_11=gather_customer_order_num_proportion_10_11[['year_month','product_name','order_num_sum','cpzl_zw','order_diff']]
customer_order_num_proportion_10_11.head()
image.png
customer_order_num_proportion_10_11 = customer_order_num_proportion_10_11[customer_order_num_proportion_10_11['product_name'].\
                                                        isin(list(customer_order_11_top10['product_name']))]
customer_order_num_proportion_10_11['category'] = '本月TOP10销量'
customer_order_num_proportion_10_11.head()
image.png
  • 11月增速TOP10产品、销售及环比
customer_order_num_proportion_11=gather_customer_order_num_proportion_10_11.loc[gather_customer_order_num_proportion_10_11['year_month'] == '2020-11'].\
                            sort_values(by = 'order_diff',ascending = False).head(10)
customer_order_num_proportion_11.head()
image.png
  • 筛选TOP10增速产品
customer_order_num_proportion_11_top10_seep = gather_customer_order_num_proportion_10_11.loc[gather_customer_order_num_proportion_10_11['product_name'].\
                                                        isin(list(customer_order_num_proportion_11['product_name']))]
#筛选出所需字段
customer_order_num_proportion_11_top10_seep = customer_order_num_proportion_11_top10_seep[['year_month','product_name','order_num_sum','cpzl_zw','order_diff']]
customer_order_num_proportion_11_top10_seep['category'] = '本月TOP10增速'
customer_order_num_proportion_11_top10_seep.head()
image.png
  • 合并TOP10销量表customer_order_month_10_11,TOP10增速customer_order_month_11_top10_seep
# axis = 0按照行维度合并,axis = 1按照列维度合并
hot_products_11 = pd.concat([customer_order_num_proportion_10_11,customer_order_num_proportion_11_top10_seep],axis = 0)
hot_products_11.tail()
image.png

图表展示:


image.png

三、看板展示

部门看板展示:

image.png

看板链接:https://app.powerbi.com/view?r=eyJrIjoiZmZiYWRhNGYtYmRkNC00ZmM5LWFhMTQtMGQ0ODMxNzNiYzhjIiwidCI6IjI0Y2NlNTc4LWM4N2MtNDA4Ny05M2EwLWFiZDRiM2YxODU5OCIsImMiOjF9&pageName=ReportSection](https://app.powerbi.com/view?r=eyJrIjoiZmZiYWRhNGYtYmRkNC00ZmM5LWFhMTQtMGQ0ODMxNzNiYzhjIiwidCI6IjI0Y2NlNTc4LWM4N2MtNDA4Ny05M2EwLWFiZDRiM2YxODU5OCIsImMiOjF9&pageName=ReportSection%20)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,372评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,368评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,415评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,157评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,171评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,125评论 1 297
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,028评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,887评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,310评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,533评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,690评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,411评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,004评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,659评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,812评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,693评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,577评论 2 353

推荐阅读更多精彩内容