【59 Pandas+Pyecharts | 淘宝华为手机商品数据分析可视化】

发布于:2025-06-12 ⋅ 阅读:(24) ⋅ 点赞:(0)


大家好,我是 👉 【Python当打之年(点击跳转)】

本期将利用Python分析「华为手机数据集」 ,看看:各系列手机销售占比、各价格区间手机销量分布、各省手机发货量地图、手机发货量TOP10城市、店铺累计手机销售额TOP10、旗舰店手机销量占比等情况,希望对大家有所帮助,如有疑问或者需要改进的地方可以联系小编。

涉及到的库:

  • Pandas — 数据处理
  • Pyecharts — 数据可视化

🏳️‍🌈 1. 导入模块

import pandas as pd
from pyecharts.charts import *
from pyecharts import options as opts
import warnings
warnings.filterwarnings('ignore')

🏳️‍🌈 2. Pandas数据处理

2.1 读取数据

df = pd.read_excel('./华为手机.xlsx')

在这里插入图片描述

2.2 数据信息

df.info()

在这里插入图片描述

2.3 数据去重

df = df.drop_duplicates()

2.4 提取付款人数

df1['付款人数'] = df1['付款人数'].fillna('0人付款')
df1 = df1[df1['付款人数'].str.contains('付款')]
df1['num'] = [re.findall(r'\d+', i)[0] for i in df1['付款人数']]

2.5 计算销量

df1['销售额'] = df1['num'] * df1['价格']
df1['销售额'] = df1['销售额'].astype('int')

2.6 发货地址处理

df1['省份'] = df1['发货地址'].str.split(' ').apply(lambda x:x[0])
df1['城市'] = df1['发货地址'].str.split(' ').apply(lambda x:x[1])

在这里插入图片描述

🏳️‍🌈 3. Pyecharts数据可视化

3.1 各系列手机销售占比

def get_pie():
    pie1 = (
        Pie()
        .add('',
             datas,
             center=['50%', '55%'],
            )
        .set_global_opts(
            visualmap_opts=opts.VisualMapOpts(
                is_show=False,
                range_color=range_color
            ),
            title_opts=opts.TitleOpts(
                title='1-华为各系列手机销售占比',
                subtitle=subtitle,
                pos_top='2%',
                pos_left="center",
            )
        )
    )

在这里插入图片描述

  • Mate(53.79%)、 Pura(16.78%)、Nova(7.05%)、畅享(22.38%)

3.2 各价格区间手机销量

def get_line():
    line = (
        Line()
        .add_xaxis(x_data)
        .add_yaxis('', y_data)
        .set_global_opts(
            title_opts=opts.TitleOpts(
                title='2-各价格区间手机销量',
                subtitle=subtitle,
                pos_top='2%',
                pos_left="center",
            ),
        )
    )

在这里插入图片描述

  • 1000-2000元区间手机购买人数最多,超过30万人付款,其次是2000-3000元区间,付款人数也超过了20万,1000-3000元区间销量占比超过了60%

3.3 各省手机发货量地图

在这里插入图片描述

  • 上图可以看出:发货地主要集中在广东、江苏、浙江、上海、山东、北京、河北等地

3.4 手机发货量TOP10城市

def get_bar():
    chart = (
        Bar()
        .add_xaxis(x_data)
        .add_yaxis('', y_data,label_opts=opts.LabelOpts(position='right'))
        .set_global_opts(
            title_opts=opts.TitleOpts(
                title='4-手机发货量TOP10城市',
                subtitle=subtitle,
                pos_top='2%',
                pos_left='center',
                ),
        )
    )

在这里插入图片描述

  • 深圳(401397)、东莞(151210)、北京(69626)、杭州(45744)、广州(32577)、上海(24253)、唐山(13116)、济南(13112)、揭阳(6450)、宁波(6017)

3.5 店铺累计手机销售额TOP10

在这里插入图片描述

  • 华为官方旗舰店(101740万)、苏宁易购官方旗舰店(15698万)、喵速达电器官方旗舰店(6274万)、华为蓝阳专卖店(5697万)、信息港数码专营店(4843万)

3.6 旗舰店手机销量占比

在这里插入图片描述

  • 旗舰店手机销量占比:61.62%

3.7 商品标题词云

def get_wordcloud():
    wordcloud = (
        WordCloud()
        .add("",data_pair=datas, word_size_range=[20, 80])
        .set_global_opts(
            title_opts=opts.TitleOpts(
                title='7-商品标题词云',
                subtitle=subtitle,
                pos_top='2%',
                pos_left="center",
                title_textstyle_opts=opts.TextStyleOpts(color=lab_color, font_size=20)
            ),
            visualmap_opts=opts.VisualMapOpts(
                is_show=False,
                range_color=range_color
            ),
        )
    )

在这里插入图片描述

🏳️‍🌈 4. 可视化项目源码+数据

点击跳转:【全部可视化项目源码+数据】


以上就是本期为大家整理的全部内容了,赶快练习起来吧,原创不易,喜欢的朋友可以点赞、收藏也可以分享注明出处)让更多人知道。