利用 python 对 shopee 四大品类商品进行数据分析

目录

  1. 数据集概要

  2. 预览数据

  3. 数据统计分析

  4. 数据可视化

    1. 四大品类的商品数量占比

    2. 四大品类的商品价格情况

    3. 四大品类的商品销量情况


数据集概要

这次数据集的基本信息:

  • 数据集大小:311条

  • 平台: Shopee

  • 品类:男鞋,手表,男包,饰品

  • 筛选标准:月销量超过1500的商品

  • 汇率:1 Rp = 0.0005 RMB

数据集来源:shopee_sales_1500_0305.csv


预览数据

预览数据集前10行数据

In [1]:
import numpy as np
import pandas as pd

data_file = 'shopee_sales_1500_0305.csv'
data = pd.read_csv(data_file)
data.head(10)
Out[1]:
category main class item name price info price monthly sales item url item picture
0 MenShoes Sandals Sandal slop kokop bulu rashfur Rp5500 5500.0 2665 https://shopee.co.id/Sandal-slop-kokop-bulu-ra... https://cf.shopee.co.id/file/d76c5c7b9583f8ece...
1 MenShoes Sandals Sandal (sendal) Masjid Musholla Wudhu Wakaf Se... Rp7000 7000.0 2275 https://shopee.co.id/Sandal-(sendal)-Masjid-Mu... https://cf.shopee.co.id/file/d094b5a9bdb5736f3...
2 MenShoes Sandals Arsy Sandal Gunung Slop / Sandal Pria - Hitam Rp14900 - Rp24900 19900.0 1563 https://shopee.co.id/Arsy-Sandal-Gunung-Slop-S... https://cf.shopee.co.id/file/28bd1c01c1ea85a05...
3 MenShoes Sneakers Sepatu Adidas Italy New Edition Size 39-43 Rp34000 34000.0 3119 https://shopee.co.id/Sepatu-Adidas-Italy-New-E... https://cf.shopee.co.id/file/12b052746c735fc65...
4 MenShoes Sneakers NIKE AIRMAX NEW EDITION 39-43 Rp45500 45500.0 2478 https://shopee.co.id/NIKE-AIRMAX-NEW-EDITION-3... https://cf.shopee.co.id/file/6346fedd27e8fb0b5...
5 MenShoes Sneakers NEW ADIDAS RUNNING NEO MAN Rp45500 45500.0 2553 https://shopee.co.id/NEW-ADIDAS-RUNNING-NEO-MA... https://cf.shopee.co.id/file/34b1094419ed8c218...
6 MenShoes Sneakers Sepatu Converse All Star The Best Quality + BO... Rp53000 53000.0 2083 https://shopee.co.id/Sepatu-Converse-All-Star-... https://cf.shopee.co.id/file/6526d93fbb2ed10ac...
7 MenShoes Sneakers IMPORT SEPATU V TALI PRIA !!! - 3 WARNA Rp79000 79000.0 1895 https://shopee.co.id/IMPORT-SEPATU-V-TALI-PRIA... https://cf.shopee.co.id/file/178c052db514fb59c...
8 MenShoes Sneakers Sepatu Nike V2 Zoom Running New Edition Size 3... Rp34000 34000.0 1883 https://shopee.co.id/Sepatu-Nike-V2-Zoom-Runni... https://cf.shopee.co.id/file/4f28cf7e985333761...
9 Watches MenWatches Jam Tangan Q&Q Jelly Angka Rubber Transparant ... Rp12000 - Rp12800 12400.0 50660 https://shopee.co.id/Jam-Tangan-Q-Q-Jelly-Angk... https://cf.shopee.co.id/file/93ddf26de1c5e258f...

注意

  • price info:商品价格信息
  • price: 如果商品有价格区间,price 为价格低点和价格高点的平均值

数据统计分析

In [99]:
import numpy as np
import pandas as pd
from PIL import Image

currency_rate = 0.0005

print('\n---------------数据集统计分析------------------\n')

fields = data.columns.tolist()
print('数据集来源:{}'.format(data_file))
print('正在统计分析数据集......')
print('数据集字段: {}'.format(fields))
category_name = data['category'].unique()
print('数据集大分类: {}'.format(category_name ))
print('数据集小分类: {}'.format(data['main class'].unique()))
data_section = data[['category','main class','price','monthly sales']]
data_name = ['价格','月销量','商品数量','最高销量','小分类']

print('\n---------------类别统计分析-------------------\n')

# 统计大分类是 MenShoes 的数据
print('正在统计 {0[0]} 的数据: {1[0]}{1[1]}{1[2]}{1[3]}{1[4]} ......'.format(category_name,data_name))
menshoes = data_section[data_section['category'] == 'MenShoes']
menshoes_pricelist = menshoes['price']* currency_rate
menshoes_saleslist = menshoes['monthly sales']
menshoes_num = menshoes.count()
menshoes_salesmax = max(menshoes_saleslist)

# 统计大分类是 Watches 的数据
print('正在统计 {0[1]} 的数据: {1[0]}{1[1]}{1[2]}{1[3]}{1[4]} ......'.format(category_name,data_name))
watches = data_section[data_section['category'] == 'Watches']
watches_pricelist = watches['price']* currency_rate
watches_saleslist = watches['monthly sales']
watches_num = watches.count()
watches_salesmax = max(watches_saleslist)
watches_class = watches['main class'].unique()
watches_class_num = [len(watches[watches['main class'] == i]) for i in watches_class ]

# 统计大分类是 Menbags 的数据
print('正在统计 {0[2]} 的数据: {1[0]}{1[1]}{1[2]}{1[3]}{1[4]} ......'.format(category_name,data_name))
menbags = data_section[data_section['category'] == 'Menbags']
menbags_pricelist = menbags['price']* currency_rate
menbags_saleslist = menbags['monthly sales']
menbags_num =  menbags.count()
menbags_salesmax = max(menbags_saleslist)

# 统计大分类是 Fashion 的数据
print('正在统计 {0[3]} 的数据: {1[0]}{1[1]}{1[2]}{1[3]}{1[4]} ......'.format(category_name,data_name))
fashion = data_section[data_section['category'] == 'Fashion']
fashion_pricelist = fashion['price']* currency_rate
fashion_saleslist = fashion['monthly sales']
fashion_num = fashion.count()
fashion_salesmax = max(fashion_saleslist)
fashion_class = fashion['main class'].unique()
fashion_class_num = [len(fashion[fashion['main class'] == i]) for i in fashion_class ]
---------------数据集统计分析------------------

数据集来源:shopee_sales_1500_0305.csv
正在统计分析数据集......
数据集字段: ['category', 'main class', 'item name', 'price info', 'price', 'monthly sales', 'item url', 'item picture']
数据集大分类: ['MenShoes' 'Watches' 'Menbags' 'Fashion']
数据集小分类: ['Sandals' 'Sneakers' 'MenWatches' 'WomenWatches' 'CoupleWatches'
 'Backpacks' 'SlingBags' 'WaistBags' 'Shoulder Bags' 'MenWallet'
 'HairAccessories' 'Hats' 'Glasses' 'ContactLenses' 'Earrings' 'Necklaces'
 'Rings' 'Bracelets' 'Belts' 'Scarf' 'AccessoriesSets']

---------------类别统计分析-------------------

正在统计 MenShoes 的数据: 价格,月销量,商品数量,最高销量,小分类 ......
正在统计 Watches 的数据: 价格,月销量,商品数量,最高销量,小分类 ......
正在统计 Menbags 的数据: 价格,月销量,商品数量,最高销量,小分类 ......
正在统计 Fashion 的数据: 价格,月销量,商品数量,最高销量,小分类 ......

数据可视化

四大品类的商品数量占比

In [149]:
from pyecharts import Pie
from pyecharts import online
online()

pie = Pie('Category percentage',title_pos='center')
pie.add('Item Number',category_name,[menshoes_num,watches_num,menbags_num,fashion_num],radius=[40, 70],label_text_color=None,is_label_show=True,legend_orient="vertical",legend_pos="left")
pie
Out[149]:

男鞋,手表,男包,饰品四大品类中月销量超过1500的商品

  • 饰品和手表数量占多数,分别是53.06%, 37.62%,其中饰品最多:165条
  • 男鞋和男包数量占少数,分别是6.43%, 2.89%,其中男鞋最少:9条

下面主要分析饰品和手表

饰品分析

In [150]:
from pyecharts import Pie

pie = Pie('Fashion accessories',title_pos='center')
pie.add('Item number',fashion_class,fashion_class_num,radius=[40, 70],label_text_color=None,is_label_show=True,legend_orient="vertical",legend_pos="Left")
pie
Out[150]:

饰品包括:眼镜,隐形眼镜/美瞳,首饰套装,头饰,帽子,项链,手镯,腰带,围巾/丝巾,戒子,耳环

其中:眼镜,隐形眼镜/美瞳 占比最高

手表分析

In [151]:
from pyecharts import Pie

pie = Pie('Watches',title_pos='center')
pie.add('Item number',watches_class,watches_class_num,radius=[40, 70],label_text_color=None,is_label_show=True,legend_orient="vertical",legend_pos="Left")
pie
Out[151]:

手表款式包括:女表,男表,情侣表

其中:女表占比最高

四大品类的商品价格情况

价格分布

In [159]:
from pyecharts import Scatter

scatter = Scatter('Price distribution','Menshoes-Watches-Menbags-Fashion')
scatter.add('MenShoes',menshoes_saleslist,menshoes_pricelist,xaxis_name ='sales',yaxis_name = 'price (rmb)',yaxis_name_gap=50,xaxis_min=1500)
scatter.add('Watches',watches_saleslist,watches_pricelist,xaxis_name ='sales',yaxis_name = 'price (rmb)',yaxis_name_gap=50,xaxis_min=1500)
scatter.add('Menbags',menbags_saleslist,menbags_pricelist,xaxis_name ='sales',yaxis_name = 'price (rmb)',yaxis_name_gap=50,xaxis_min=1500)
scatter.add('Fashion',fashion_saleslist,fashion_pricelist,xaxis_name ='sales',yaxis_name = 'price (rmb)',yaxis_name_gap=50,xaxis_min=1500)
scatter
Out[159]:
  • 男鞋 价格分布在0-40元之间
  • 手表 价格集中在0-20元之间
  • 男包 价格集中在10-30元之间
  • 饰品 价格集中在0-20元之间

价格峰值

In [154]:
from pyecharts import Boxplot

boxplot = Boxplot('Price peak')
x_axis = data['category'].unique()
y_axis = [menshoes_pricelist,watches_pricelist,menbags_pricelist,fashion_pricelist]
boxplot.add("price", x_axis, boxplot.prepare_data(y_axis))
num = 0
for box in boxplot.prepare_data(y_axis):
    print(x_axis[num])
    print("min 最小值:{0[0]} / Q1下四分位数:{0[1]} / median(or Q2)中位数:{0[2]} / Q3上四分位数:{0[3]} / max最大值:{0[4]}".format(box,x_axis))
    num += 1
boxplot
MenShoes
min 最小值:2.75 / Q1下四分位数:6.7250000000000005 / median(or Q2)中位数:17.0 / Q3上四分位数:24.625 / max最大值:39.5
Watches
min 最小值:0.375 / Q1下四分位数:5.75 / median(or Q2)中位数:7.1000000000000005 / Q3上四分位数:12.725000000000001 / max最大值:75.0
Menbags
min 最小值:9.0 / Q1下四分位数:11.25 / median(or Q2)中位数:20.775000000000002 / Q3上四分位数:28.0625 / max最大值:50.0
Fashion
min 最小值:0.2 / Q1下四分位数:3.4000000000000004 / median(or Q2)中位数:5.95 / Q3上四分位数:11.2625 / max最大值:51.23075
Out[154]:
  • 男鞋 最高价格 39.5 元
  • 手表 最高价格 75 元
  • 男包 最高价格 50 元
  • 饰品 最高价格 51 元

四大品类的商品销量情况

销量分布

In [158]:
from pyecharts import Scatter

scatter = Scatter('Sales distribution','Menshoes-Watches-Menbags-Fashion')
scatter.add('MenShoes',menshoes_pricelist,menshoes_saleslist,yaxis_name ='sales',xaxis_name = 'price (rmb)',yaxis_name_gap=50,yaxis_min=1500)
scatter.add('Watches',watches_pricelist,watches_saleslist,yaxis_name ='sales',xaxis_name = 'price (rmb)',yaxis_name_gap=50,yaxis_min=1500)
scatter.add('Menbags',menbags_pricelist,menbags_saleslist,yaxis_name ='sales',xaxis_name = 'price (rmb)',yaxis_name_gap=50,yaxis_min=1500)
scatter.add('Fashion',fashion_pricelist,fashion_saleslist,yaxis_name ='sales',xaxis_name = 'price (rmb)',yaxis_name_gap=50,yaxis_min=1500)
scatter
Out[158]:
  • 男鞋 销量分布在 1500-3119 件之间
  • 手表 销量集中在 1500-10000 件之间
  • 男包 销量集中在 1500-4000 件之间
  • 饰品 销量集中在 1500-10000 件之间
In [156]:
from pyecharts import Boxplot

boxplot = Boxplot('Sales peak')
x_axis = data['category'].unique()
y_axis = [menshoes_saleslist,watches_saleslist,menbags_saleslist,fashion_saleslist]
boxplot.add("sales", x_axis, boxplot.prepare_data(y_axis))
num = 0
for box in boxplot.prepare_data(y_axis):
    print(x_axis[num])
    print("min 最小值:{0[0]} / Q1下四分位数:{0[1]} / median(or Q2)中位数:{0[2]} / Q3上四分位数:{0[3]} / max最大值:{0[4]}".format(box,x_axis))
    num += 1
boxplot
MenShoes
min 最小值:1563 / Q1下四分位数:1889.0 / median(or Q2)中位数:2275 / Q3上四分位数:2609.0 / max最大值:3119
Watches
min 最小值:1538 / Q1下四分位数:1933.0 / median(or Q2)中位数:2750 / Q3上四分位数:4396.0 / max最大值:50660
Menbags
min 最小值:1536 / Q1下四分位数:1834.5 / median(or Q2)中位数:2373.5 / Q3上四分位数:3007.0 / max最大值:13768
Fashion
min 最小值:1500 / Q1下四分位数:2035.5 / median(or Q2)中位数:2651 / Q3上四分位数:4325.5 / max最大值:63504
Out[156]:
  • 男鞋 最高销量 3119 件
  • 手表 最高销量 50660 件
  • 男包 最高销量 13768 件
  • 饰品 最高销量 63504 件