项目介绍:
黑色星期五是美国感恩节后一天,圣诞节前的一次大采购活动,当天一般美国商场会推出大量的打折优惠、促销活动, 由于美国的商场一般以红笔记录赤字,以黑笔记录盈利,而感恩节后的这个星期五人们疯狂的抢购使得商场利润大增,因此被商家们称作黑色星期五。 商家期望通过以这一天开始的圣诞大采购为这一年获得最多的盈利。
分析目的:
本次的分析数据来自于Kaggle提供的某电商黑色星期五的销售记录, 参考网上的分析思路,将围绕产品和用户两大方面展开叙述,为电商平台制定策略提供分析及建议。
本文分析的主要框架
1.整体消费的情况
2.用户画像分析(探究最优价值的用户类型:性别、年龄、职业、婚姻)
3.城市业绩分析(城市分布 、居住年限分布)
3.产品分析(探究最优价值的产品) 细化分析:产品销售额Top 5产品、产品销售额Top5 产品类别
4.最大贡献用户价值分析: 客单价、价值Top1000用户清单、价值Top1000用户情况
5.结论以及建议
import pandas as pd
import numpy as np
import matplotlib as plt
%matplotlib inline
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
import seaborn as sns
df = pd.read_csv('D:\\BaiduNetdiskDownload\\practise\\Third Program\\BlackFriday.csv')
df.head()
User_ID | Product_ID | Gender | Age | Occupation | City_Category | Stay_In_Current_City_Years | Marital_Status | Product_Category_1 | Product_Category_2 | Product_Category_3 | Purchase | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1000001 | P00069042 | F | 0-17 | 10 | A | 2 | 0 | 3 | NaN | NaN | 8370 |
1 | 1000001 | P00248942 | F | 0-17 | 10 | A | 2 | 0 | 1 | 6.0 | 14.0 | 15200 |
2 | 1000001 | P00087842 | F | 0-17 | 10 | A | 2 | 0 | 12 | NaN | NaN | 1422 |
3 | 1000001 | P00085442 | F | 0-17 | 10 | A | 2 | 0 | 12 | 14.0 | NaN | 1057 |
4 | 1000002 | P00285442 | M | 55+ | 16 | C | 4+ | 0 | 8 | NaN | NaN | 7969 |
原始数据中共有12个字段,解释如下:
User_ID: 用户ID
Product_ID: 产品ID
Gender: 性别
Age: 年龄
Occupation: 职业
City_Category: 城市(A,B,C)
Stay_In_Current_City_Years: 居住时长
Marital_Status: 婚姻状况
Product_Category_1 产品类别1,是一级分类
Product_Category_2 产品类别2,是二级分类
Product_Category_3 产品类别3,是三级分类
Purchase: 金额(美元)
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 537577 entries, 0 to 537576
Data columns (total 12 columns):
User_ID 537577 non-null int64
Product_ID 537577 non-null object
Gender 537577 non-null object
Age 537577 non-null object
Occupation 537577 non-null int64
City_Category 537577 non-null object
Stay_In_Current_City_Years 537577 non-null object
Marital_Status 537577 non-null int64
Product_Category_1 537577 non-null int64
Product_Category_2 370591 non-null float64
Product_Category_3 164278 non-null float64
Purchase 537577 non-null int64
dtypes: float64(2), int64(5), object(5)
memory usage: 49.2+ MB
1、整体消费情况
df.describe()
User_ID | Occupation | Marital_Status | Product_Category_1 | Product_Category_2 | Product_Category_3 | Purchase | |
---|---|---|---|---|---|---|---|
count | 5.375770e+05 | 537577.00000 | 537577.000000 | 537577.000000 | 370591.000000 | 164278.000000 | 537577.000000 |
mean | 1.002992e+06 | 8.08271 | 0.408797 | 5.295546 | 9.842144 | 12.669840 | 9333.859853 |
std | 1.714393e+03 | 6.52412 | 0.491612 | 3.750701 | 5.087259 | 4.124341 | 4981.022133 |
min | 1.000001e+06 | 0.00000 | 0.000000 | 1.000000 | 2.000000 | 3.000000 | 185.000000 |
25% | 1.001495e+06 | 2.00000 | 0.000000 | 1.000000 | 5.000000 | 9.000000 | 5866.000000 |
50% | 1.003031e+06 | 7.00000 | 0.000000 | 5.000000 | 9.000000 | 14.000000 | 8062.000000 |
75% | 1.004417e+06 | 14.00000 | 1.000000 | 8.000000 | 15.000000 | 16.000000 | 12073.000000 |
max | 1.006040e+06 | 20.00000 | 1.000000 | 18.000000 | 18.000000 | 18.000000 | 23961.000000 |
df['Purchase'].sum()/df['User_ID'].drop_duplicates(keep='first').count()#平均客单价是85万美元
851751.5494822611
从本次的消费记录来看,记录的主要是大客户的消费数据,人均消费已经达到了85万美元!这些人一共贡献了50亿美金的销售额。抓住忠实用户,并促进他们消费,是互联网电商发展的基本操作。
2、从用户的角度来分析问题
(1)性别方面
#df_gender_purchase=df.groupby("Gender").agg({"Purchase":"sum"}).reset_index().rename(columns={"Purchase":"Purchase_amount"})
df_gender_purchase=df.groupby('Gender').agg({
'Purchase':'sum'}).reset_index().rename(columns={
'Purchase':'Purchase_amount'})
df_gender_purchase['gender_purchase_pro']=df_gender_purchase.apply(lambda x: x[1]/df['Purchase'].sum(),axis=1)
def Gender_user_count(x):
if x[0]=='F':
return df.loc[df['Gender']=='F'].drop_duplicates('User_ID',keep='first')['User_ID'].count()
if x[0]=='M':
return df.loc[df['Gender']=='M'].drop_duplicates('User_ID',keep='first')['User_ID'].count()
df_gender_purchase['gender_user_count']=df_gender_purchase.apply(lambda x:Gender_user_count(x),axis=1)
df_gender_purchase['gender_customer_price']=df_gender_purchase.apply(lambda x:x[1]/x[3],axis=1)
df_gender_purchase['gender_count_prop']=df_gender_purchase.apply(lambda x:x[3]/df_gender_purchase['gender_user_count'].sum(),axis=1)
df_gender_purchase
Gender | Purchase_amount | gender_purchase_pro | gender_user_count | gender_customer_price | gender_count_prop | |
---|---|---|---|---|---|---|
0 | F | 1164624021 | 0.232105 | 1666 | 699054.034214 | 0.282804 |
1 | M | 3853044357 | 0.767895 | 4225 | 911963.161420 | 0.717196 |
在黑色星期五的活动中,男性是占据了71%的用户,将近是女性的2.5倍;但是贡献了将近76%的销售额,是女生的3.3倍;显然是有跟多的男性参与这个活动,并且客单价还是较高于女性, 所以应该针对男性用价格较高的产品来推