{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "human-franchise",
   "metadata": {},
   "source": [
    "# 前言\n",
    "\n",
    "数据源是来自[和鲸社区](https://www.kesci.com/mw/dataset/5ffac64f3441fd001538228b/file)的 3 份互不相关的电商数据集，所以分成 3 部分，每部分只对其中的一个数据集进行分析。\n",
    "\n",
    "\n",
    "## part 1\n",
    "\n",
    "tmall_order_report.csv 这个数据集是订单数据，可供挖掘的纬度有订单时间、省份（收货地址），指标则有销售量、销售额、退款金额、退货率、成交率、地区分布、下单时间趋势等。\n",
    "\n",
    "### 1、数据理解与处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "hawaiian-tournament",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单编号</th>\n",
       "      <th>总金额</th>\n",
       "      <th>买家实际支付金额</th>\n",
       "      <th>收货地址</th>\n",
       "      <th>订单创建时间</th>\n",
       "      <th>订单付款时间</th>\n",
       "      <th>退款金额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>178.8</td>\n",
       "      <td>0.0</td>\n",
       "      <td>上海</td>\n",
       "      <td>2020-02-21 00:00:00</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>21.0</td>\n",
       "      <td>21.0</td>\n",
       "      <td>内蒙古自治区</td>\n",
       "      <td>2020-02-20 23:59:54</td>\n",
       "      <td>2020-02-21 00:00:02</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>37.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>安徽省</td>\n",
       "      <td>2020-02-20 23:59:35</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>157.0</td>\n",
       "      <td>157.0</td>\n",
       "      <td>湖南省</td>\n",
       "      <td>2020-02-20 23:58:34</td>\n",
       "      <td>2020-02-20 23:58:44</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>64.8</td>\n",
       "      <td>0.0</td>\n",
       "      <td>江苏省</td>\n",
       "      <td>2020-02-20 23:57:04</td>\n",
       "      <td>2020-02-20 23:57:11</td>\n",
       "      <td>64.8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   订单编号    总金额  买家实际支付金额   收货地址                订单创建时间              订单付款时间   \\\n",
       "0     1  178.8       0.0      上海  2020-02-21 00:00:00                  NaN   \n",
       "1     2   21.0      21.0  内蒙古自治区  2020-02-20 23:59:54  2020-02-21 00:00:02   \n",
       "2     3   37.0       0.0     安徽省  2020-02-20 23:59:35                  NaN   \n",
       "3     4  157.0     157.0     湖南省  2020-02-20 23:58:34  2020-02-20 23:58:44   \n",
       "4     5   64.8       0.0     江苏省  2020-02-20 23:57:04  2020-02-20 23:57:11   \n",
       "\n",
       "   退款金额  \n",
       "0   0.0  \n",
       "1   0.0  \n",
       "2   0.0  \n",
       "3   0.0  \n",
       "4  64.8  "
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "data = pd.read_csv('tmall_order_report.csv')\n",
    "data.head() # 退款金额应该就是客户退货后，返还给客户的退款金额"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "dependent-analyst",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 28010 entries, 0 to 28009\n",
      "Data columns (total 7 columns):\n",
      " #   Column    Non-Null Count  Dtype  \n",
      "---  ------    --------------  -----  \n",
      " 0   订单编号      28010 non-null  int64  \n",
      " 1   总金额       28010 non-null  float64\n",
      " 2   买家实际支付金额  28010 non-null  float64\n",
      " 3   收货地址      28010 non-null  object \n",
      " 4   订单创建时间    28010 non-null  object \n",
      " 5   订单付款时间    24087 non-null  object \n",
      " 6   退款金额      28010 non-null  float64\n",
      "dtypes: float64(3), int64(1), object(3)\n",
      "memory usage: 1.5+ MB\n"
     ]
    }
   ],
   "source": [
    "data.info()  # 数据集情况 28010 条，6个字段"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "central-green",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['订单编号', '总金额', '买家实际支付金额', '收货地址', '订单创建时间', '订单付款时间', '退款金额'], dtype='object')"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.columns = data.columns.str.strip()  # 列名有空格，需要处理下\n",
    "data.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "decreased-sector",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "订单编号        0\n",
       "总金额         0\n",
       "买家实际支付金额    0\n",
       "收货地址        0\n",
       "订单创建时间      0\n",
       "订单付款时间      0\n",
       "退款金额        0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[data.duplicated()].count()  # 没有完全重复的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "american-chuck",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "订单编号           0\n",
       "总金额            0\n",
       "买家实际支付金额       0\n",
       "收货地址           0\n",
       "订单创建时间         0\n",
       "订单付款时间      3923\n",
       "退款金额           0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.isnull().sum()   # 付款时间存在空值，表示订单未付款"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "caring-flavor",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['上海', '内蒙古', '安徽', '湖南', '江苏', '浙江', '天津', '北京', '四川', '贵州', '辽宁',\n",
       "       '河南', '广西', '广东', '福建', '海南', '江西', '甘肃', '河北', '黑龙江', '云南', '重庆',\n",
       "       '山西', '吉林', '山东', '陕西', '湖北', '青海', '新疆', '宁夏', '西藏'], dtype=object)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['收货地址'] = data['收货地址'].str.replace('自治区|维吾尔|回族|壮族|省', '')  # 对省份做个清洗，便于可视化\n",
    "data['收货地址'].unique()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "rocky-employee",
   "metadata": {},
   "source": [
    "### 2、数据分析可视化"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "continent-alpha",
   "metadata": {},
   "source": [
    "#### 2.1 整体情况"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "spanish-aerospace",
   "metadata": {},
   "outputs": [],
   "source": [
    "result = {}\n",
    "result['总订单数'] = data['订单编号'].count()  \n",
    "result['已完成订单数'] = data['订单编号'][data['订单付款时间'].notnull()].count()  \n",
    "result['未付款订单数'] = data['订单编号'][data['订单付款时间'].isnull()].count()  \n",
    "result['退款订单数'] = data['订单编号'][data['退款金额'] > 0].count()  \n",
    "result['总订单金额'] = data['总金额'][data['订单付款时间'].notnull()].sum()  \n",
    "result['总退款金额'] = data['退款金额'][data['订单付款时间'].notnull()].sum()  \n",
    "result['总实际收入金额'] = data['买家实际支付金额'][data['订单付款时间'].notnull()].sum()  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "surgical-settle",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'总订单数': 28010,\n",
       " '已完成订单数': 24087,\n",
       " '未付款订单数': 3923,\n",
       " '退款订单数': 5646,\n",
       " '总订单金额': 2474823.0700000003,\n",
       " '总退款金额': 572335.9199999999,\n",
       " '总实际收入金额': 1902487.1500000001}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "direct-diana",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "            <style>\n",
       "            .fl-table {\n",
       "                margin: 20px;\n",
       "                border-radius: 5px;\n",
       "                font-size: 12px;\n",
       "                border: none;\n",
       "                border-collapse: collapse;\n",
       "                max-width: 100%;\n",
       "                white-space: nowrap;\n",
       "                word-break: keep-all;\n",
       "            }\n",
       "\n",
       "            .fl-table th {\n",
       "                text-align: left;\n",
       "                font-size: 20px;\n",
       "            }\n",
       "\n",
       "            .fl-table tr {\n",
       "                display: table-row;\n",
       "                vertical-align: inherit;\n",
       "                border-color: inherit;\n",
       "            }\n",
       "\n",
       "            .fl-table tr:hover td {\n",
       "                background: #00d1b2;\n",
       "                color: #F8F8F8;\n",
       "            }\n",
       "\n",
       "            .fl-table td, .fl-table th {\n",
       "                border-style: none;\n",
       "                border-top: 1px solid #dbdbdb;\n",
       "                border-left: 1px solid #dbdbdb;\n",
       "                border-bottom: 3px solid #dbdbdb;\n",
       "                border-right: 1px solid #dbdbdb;\n",
       "                padding: .5em .55em;\n",
       "                font-size: 15px;\n",
       "            }\n",
       "\n",
       "            .fl-table td {\n",
       "                border-style: none;\n",
       "                font-size: 15px;\n",
       "                vertical-align: center;\n",
       "                border-bottom: 1px solid #dbdbdb;\n",
       "                border-left: 1px solid #dbdbdb;\n",
       "                border-right: 1px solid #dbdbdb;\n",
       "                height: 30px;\n",
       "            }\n",
       "\n",
       "            .fl-table tr:nth-child(even) {\n",
       "                background: #F8F8F8;\n",
       "            }\n",
       "        </style>\n",
       "        <div id=\"1b5eb8efc4434ea99ffef941ff7b6f64\" class=\"chart-container\" style=\"\">\n",
       "            <p class=\"title\" style=\"font-size: 18px; font-weight:bold;\" > 整体情况</p>\n",
       "            <p class=\"subtitle\" style=\"font-size: 12px;\" > </p>\n",
       "            <table class=\"fl-table\">\n",
       "    <thead>\n",
       "        <tr>\n",
       "            <th>总订单数</th>\n",
       "            <th>总订单金额</th>\n",
       "            <th>已完成订单数</th>\n",
       "            <th>总实际收入金额</th>\n",
       "            <th>退款订单数</th>\n",
       "            <th>总退款金额</th>\n",
       "            <th>成交率</th>\n",
       "            <th>退货率</th>\n",
       "        </tr>\n",
       "    </thead>\n",
       "    <tbody>\n",
       "        <tr>\n",
       "            <td>28010</td>\n",
       "            <td>247.48 万</td>\n",
       "            <td>24087</td>\n",
       "            <td>190.25 万</td>\n",
       "            <td>5646</td>\n",
       "            <td>57.23 万</td>\n",
       "            <td>85.99%</td>\n",
       "            <td>23.44%</td>\n",
       "        </tr>\n",
       "    </tbody>\n",
       "</table>\n",
       "        </div>\n",
       "\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1c77d027320>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Map, Bar, Line\n",
    "from pyecharts.components import Table\n",
    "from pyecharts.options import ComponentTitleOpts\n",
    "from pyecharts.faker import Faker\n",
    "\n",
    "table = Table()\n",
    "\n",
    "headers = ['总订单数', '总订单金额', '已完成订单数', '总实际收入金额', '退款订单数', '总退款金额', '成交率', '退货率']\n",
    "rows = [\n",
    "    [\n",
    "        result['总订单数'], f\"{result['总订单金额']/10000:.2f} 万\", result['已完成订单数'], f\"{result['总实际收入金额']/10000:.2f} 万\",\n",
    "        result['退款订单数'], f\"{result['总退款金额']/10000:.2f} 万\", \n",
    "        f\"{result['已完成订单数']/result['总订单数']:.2%}\",\n",
    "        f\"{result['退款订单数']/result['已完成订单数']:.2%}\",\n",
    "    ]\n",
    "]\n",
    "table.add(headers, rows)\n",
    "table.set_global_opts(\n",
    "    title_opts=ComponentTitleOpts(title='整体情况')\n",
    ")\n",
    "table.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "young-insert",
   "metadata": {},
   "source": [
    "#### 2.2 地区分析"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "still-cradle",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'china':'https://assets.pyecharts.org/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"dd9c312d14084a61afb0d5cde2ca123f\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_dd9c312d14084a61afb0d5cde2ca123f = echarts.init(\n",
       "                    document.getElementById('dd9c312d14084a61afb0d5cde2ca123f'), 'white', {renderer: 'canvas'});\n",
       "                var option_dd9c312d14084a61afb0d5cde2ca123f = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"map\",\n",
       "            \"name\": \"\\u8ba2\\u5355\\u91cf\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"mapType\": \"china\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u4e0a\\u6d77\",\n",
       "                    \"value\": 3060\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e91\\u5357\",\n",
       "                    \"value\": 667\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5185\\u8499\\u53e4\",\n",
       "                    \"value\": 176\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5317\\u4eac\",\n",
       "                    \"value\": 1853\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5409\\u6797\",\n",
       "                    \"value\": 336\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u56db\\u5ddd\",\n",
       "                    \"value\": 1752\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5929\\u6d25\",\n",
       "                    \"value\": 1031\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b81\\u590f\",\n",
       "                    \"value\": 40\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u5fbd\",\n",
       "                    \"value\": 528\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u4e1c\",\n",
       "                    \"value\": 1484\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u897f\",\n",
       "                    \"value\": 395\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u4e1c\",\n",
       "                    \"value\": 2022\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u897f\",\n",
       "                    \"value\": 353\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u7586\",\n",
       "                    \"value\": 43\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u82cf\",\n",
       "                    \"value\": 1845\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u897f\",\n",
       "                    \"value\": 331\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5317\",\n",
       "                    \"value\": 885\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5357\",\n",
       "                    \"value\": 792\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d59\\u6c5f\",\n",
       "                    \"value\": 1822\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d77\\u5357\",\n",
       "                    \"value\": 156\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5317\",\n",
       "                    \"value\": 57\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5357\",\n",
       "                    \"value\": 935\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7518\\u8083\",\n",
       "                    \"value\": 132\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u798f\\u5efa\",\n",
       "                    \"value\": 425\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f\\u85cf\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d35\\u5dde\",\n",
       "                    \"value\": 286\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8fbd\\u5b81\",\n",
       "                    \"value\": 1012\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u91cd\\u5e86\",\n",
       "                    \"value\": 896\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9655\\u897f\",\n",
       "                    \"value\": 441\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9752\\u6d77\",\n",
       "                    \"value\": 18\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ed1\\u9f99\\u6c5f\",\n",
       "                    \"value\": 312\n",
       "                }\n",
       "            ],\n",
       "            \"roam\": true,\n",
       "            \"aspectScale\": 0.75,\n",
       "            \"nameProperty\": \"name\",\n",
       "            \"selectedMode\": false,\n",
       "            \"zoom\": 1,\n",
       "            \"mapValueCalculation\": \"sum\",\n",
       "            \"showLegendSymbol\": false,\n",
       "            \"emphasis\": {},\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8ba2\\u5355\\u91cf\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u8ba2\\u5355\\u91cf\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5730\\u533a\\u5206\\u5e03\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"continuous\",\n",
       "        \"min\": 0,\n",
       "        \"max\": 1000,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"#50a3ba\",\n",
       "                \"#eac763\",\n",
       "                \"#d94e5d\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 140,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "                chart_dd9c312d14084a61afb0d5cde2ca123f.setOption(option_dd9c312d14084a61afb0d5cde2ca123f);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1c77df05c50>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result2 = data[data['订单付款时间'].notnull()].groupby('收货地址').agg({'订单编号':'count'})\n",
    "result21 = result2.to_dict()['订单编号']\n",
    "c = (\n",
    "    Map()\n",
    "    .add(\"订单量\", [*result21.items()], \"china\", is_map_symbol_show=False)\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(is_show=True))\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title='地区分布'),\n",
    "        visualmap_opts=opts.VisualMapOpts(max_=1000),            \n",
    "    )\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "hungry-bangkok",
   "metadata": {},
   "source": [
    "#### 2.3 时间分析"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "behavioral-mumbai",
   "metadata": {},
   "outputs": [],
   "source": [
    "data['订单创建时间'] = pd.to_datetime(data['订单创建时间'])\n",
    "data['订单付款时间'] = pd.to_datetime(data['订单付款时间'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "rough-torture",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"fd054a4fc52a4c288d19692f728b4a43\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_fd054a4fc52a4c288d19692f728b4a43 = echarts.init(\n",
       "                    document.getElementById('fd054a4fc52a4c288d19692f728b4a43'), 'white', {renderer: 'canvas'});\n",
       "                var option_fd054a4fc52a4c288d19692f728b4a43 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u8ba2\\u5355\\u91cf\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2020-02-01\",\n",
       "                    176\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-02\",\n",
       "                    222\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-03\",\n",
       "                    267\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-04\",\n",
       "                    469\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-05\",\n",
       "                    369\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-06\",\n",
       "                    144\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-07\",\n",
       "                    177\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-09\",\n",
       "                    404\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-10\",\n",
       "                    27\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-11\",\n",
       "                    15\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-12\",\n",
       "                    1\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-13\",\n",
       "                    5\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-14\",\n",
       "                    7\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-15\",\n",
       "                    5\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-17\",\n",
       "                    390\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-18\",\n",
       "                    1015\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-19\",\n",
       "                    1025\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-20\",\n",
       "                    1345\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-21\",\n",
       "                    2068\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-22\",\n",
       "                    2027\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-23\",\n",
       "                    2200\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-24\",\n",
       "                    1998\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-25\",\n",
       "                    3416\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-26\",\n",
       "                    2849\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-27\",\n",
       "                    2586\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-28\",\n",
       "                    2691\n",
       "                ],\n",
       "                [\n",
       "                    \"2020-02-29\",\n",
       "                    2112\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5927\\u503c\",\n",
       "                        \"type\": \"max\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0,\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8ba2\\u5355\\u91cf\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u8ba2\\u5355\\u91cf\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2020-02-01\",\n",
       "                \"2020-02-02\",\n",
       "                \"2020-02-03\",\n",
       "                \"2020-02-04\",\n",
       "                \"2020-02-05\",\n",
       "                \"2020-02-06\",\n",
       "                \"2020-02-07\",\n",
       "                \"2020-02-09\",\n",
       "                \"2020-02-10\",\n",
       "                \"2020-02-11\",\n",
       "                \"2020-02-12\",\n",
       "                \"2020-02-13\",\n",
       "                \"2020-02-14\",\n",
       "                \"2020-02-15\",\n",
       "                \"2020-02-17\",\n",
       "                \"2020-02-18\",\n",
       "                \"2020-02-19\",\n",
       "                \"2020-02-20\",\n",
       "                \"2020-02-21\",\n",
       "                \"2020-02-22\",\n",
       "                \"2020-02-23\",\n",
       "                \"2020-02-24\",\n",
       "                \"2020-02-25\",\n",
       "                \"2020-02-26\",\n",
       "                \"2020-02-27\",\n",
       "                \"2020-02-28\",\n",
       "                \"2020-02-29\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6bcf\\u65e5\\u8ba2\\u5355\\u91cf\\u8d70\\u52bf\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_fd054a4fc52a4c288d19692f728b4a43.setOption(option_fd054a4fc52a4c288d19692f728b4a43);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1c77b84ef28>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result31 = data.groupby(data['订单创建时间'].apply(lambda x: x.strftime(\"%Y-%m-%d\"))).agg({'订单编号':'count'}).to_dict()['订单编号']\n",
    "c = (\n",
    "    Line()\n",
    "    .add_xaxis(list(result31.keys()))\n",
    "    .add_yaxis(\"订单量\", list(result31.values()))\n",
    "    .set_series_opts(\n",
    "        label_opts=opts.LabelOpts(is_show=False),\n",
    "        markpoint_opts=opts.MarkPointOpts(\n",
    "            data=[\n",
    "                opts.MarkPointItem(type_=\"max\", name=\"最大值\"),\n",
    "            ]\n",
    "        ),\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"每日订单量走势\"))\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "nasty-priority",
   "metadata": {},
   "source": [
    "从上图来看，2月份上半月由于受新冠疫情影响，订单量比较少，随着复工开展，下半月的订单量增长明显。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "existing-hungarian",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"2d0d294801e84e3aaedd0add2f504ebe\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_2d0d294801e84e3aaedd0add2f504ebe = echarts.init(\n",
       "                    document.getElementById('2d0d294801e84e3aaedd0add2f504ebe'), 'white', {renderer: 'canvas'});\n",
       "                var option_2d0d294801e84e3aaedd0add2f504ebe = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8ba2\\u5355\\u91cf\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                1043,\n",
       "                530,\n",
       "                341,\n",
       "                189,\n",
       "                135,\n",
       "                113,\n",
       "                250,\n",
       "                556,\n",
       "                880,\n",
       "                1283,\n",
       "                1672,\n",
       "                1640,\n",
       "                1367,\n",
       "                1339,\n",
       "                1500,\n",
       "                1720,\n",
       "                1481,\n",
       "                1205,\n",
       "                1270,\n",
       "                1532,\n",
       "                1990,\n",
       "                2204,\n",
       "                2126,\n",
       "                1644\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"name\": \"\\u5cf0\\u503c\",\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u7b2c\\u4e8c\\u5cf0\\u503c\",\n",
       "                        \"coord\": [\n",
       "                            \"15\",\n",
       "                            1720\n",
       "                        ],\n",
       "                        \"value\": 1720\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u7b2c\\u4e09\\u5cf0\\u503c\",\n",
       "                        \"coord\": [\n",
       "                            \"10\",\n",
       "                            1672\n",
       "                        ],\n",
       "                        \"value\": 1672\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8ba2\\u5355\\u91cf\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u8ba2\\u5355\\u91cf\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"00\",\n",
       "                \"01\",\n",
       "                \"02\",\n",
       "                \"03\",\n",
       "                \"04\",\n",
       "                \"05\",\n",
       "                \"06\",\n",
       "                \"07\",\n",
       "                \"08\",\n",
       "                \"09\",\n",
       "                \"10\",\n",
       "                \"11\",\n",
       "                \"12\",\n",
       "                \"13\",\n",
       "                \"14\",\n",
       "                \"15\",\n",
       "                \"16\",\n",
       "                \"17\",\n",
       "                \"18\",\n",
       "                \"19\",\n",
       "                \"20\",\n",
       "                \"21\",\n",
       "                \"22\",\n",
       "                \"23\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6bcf\\u5c0f\\u65f6\\u8ba2\\u5355\\u91cf\\u8d70\\u52bf\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_2d0d294801e84e3aaedd0add2f504ebe.setOption(option_2d0d294801e84e3aaedd0add2f504ebe);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1c77df05278>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result32 = data.groupby(data['订单创建时间'].apply(lambda x: x.strftime(\"%H\"))).agg({'订单编号':'count'}).to_dict()['订单编号']\n",
    "x = [*result32.keys()]\n",
    "y = [*result32.values()]\n",
    "c = (\n",
    "    Bar()\n",
    "    .add_xaxis(x)\n",
    "    .add_yaxis(\"订单量\", y)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"每小时订单量走势\"))\n",
    "    .set_series_opts(\n",
    "        label_opts=opts.LabelOpts(is_show=False),\n",
    "        markpoint_opts=opts.MarkPointOpts(\n",
    "            data=[\n",
    "                opts.MarkPointItem(type_=\"max\", name=\"峰值\"),\n",
    "                opts.MarkPointItem(name=\"第二峰值\", coord=[x[15], y[15]], value=y[15]),\n",
    "                opts.MarkPointItem(name=\"第三峰值\", coord=[x[10], y[10]], value=y[10]),\n",
    "            ]\n",
    "        ),\n",
    "    )\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "protecting-berkeley",
   "metadata": {},
   "source": [
    "从每小时订单量走势来看，一天中有3个高峰期（10点、15点、21点），其中21点-22点之间是一天中订单量最多的时候，这个结果和之前 [1 亿条淘宝用户行为数据分析](https://github.com/TurboWay/bigdata_analyse/blob/main/UserBehaviorFromTaobao_Batch/用户行为数据分析.md) 的结果是一致的。对于卖家的指导意义就是，为了提高订单量，高峰期时应该尽量保证客服的回复速度，尤其是晚上21点-22点之间，所以很多做电商的基本都有夜班。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "functional-yeast",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7.7399046511949745"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = data['订单付款时间'] - data['订单创建时间']\n",
    "s[s.notnull()].apply(lambda x: x.seconds / 60 ).mean()  # 从下单到付款的平均耗时为 7.7 分钟"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "running-conspiracy",
   "metadata": {},
   "source": [
    "## part2\n",
    "\n",
    "双十一淘宝美妆数据.csv 这个数据集是美妆店铺的双十一销售数据，可以挖掘的纬度有日期、店铺，指标则有销售量、销售额、评论数等。\n",
    "### 1、数据理解与处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "fresh-episode",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>update_time</th>\n",
       "      <th>id</th>\n",
       "      <th>title</th>\n",
       "      <th>price</th>\n",
       "      <th>sale_count</th>\n",
       "      <th>comment_count</th>\n",
       "      <th>店名</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2016/11/14</td>\n",
       "      <td>A18164178225</td>\n",
       "      <td>CHANDO/自然堂 雪域精粹纯粹滋润霜50g 补水保湿 滋润水润面霜</td>\n",
       "      <td>139.0</td>\n",
       "      <td>26719.0</td>\n",
       "      <td>2704.0</td>\n",
       "      <td>自然堂</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2016/11/14</td>\n",
       "      <td>A18177105952</td>\n",
       "      <td>CHANDO/自然堂凝时鲜颜肌活乳液120ML 淡化细纹补水滋润专柜正品</td>\n",
       "      <td>194.0</td>\n",
       "      <td>8122.0</td>\n",
       "      <td>1492.0</td>\n",
       "      <td>自然堂</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2016/11/14</td>\n",
       "      <td>A18177226992</td>\n",
       "      <td>CHANDO/自然堂活泉保湿修护精华水（滋润型135ml 补水控油爽肤水</td>\n",
       "      <td>99.0</td>\n",
       "      <td>12668.0</td>\n",
       "      <td>589.0</td>\n",
       "      <td>自然堂</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2016/11/14</td>\n",
       "      <td>A18178033846</td>\n",
       "      <td>CHANDO/自然堂 男士劲爽控油洁面膏 100g 深层清洁  男士洗面奶</td>\n",
       "      <td>38.0</td>\n",
       "      <td>25805.0</td>\n",
       "      <td>4287.0</td>\n",
       "      <td>自然堂</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2016/11/14</td>\n",
       "      <td>A18178045259</td>\n",
       "      <td>CHANDO/自然堂雪域精粹纯粹滋润霜（清爽型）50g补水保湿滋润霜</td>\n",
       "      <td>139.0</td>\n",
       "      <td>5196.0</td>\n",
       "      <td>618.0</td>\n",
       "      <td>自然堂</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  update_time            id                                  title  price  \\\n",
       "0  2016/11/14  A18164178225    CHANDO/自然堂 雪域精粹纯粹滋润霜50g 补水保湿 滋润水润面霜  139.0   \n",
       "1  2016/11/14  A18177105952   CHANDO/自然堂凝时鲜颜肌活乳液120ML 淡化细纹补水滋润专柜正品  194.0   \n",
       "2  2016/11/14  A18177226992   CHANDO/自然堂活泉保湿修护精华水（滋润型135ml 补水控油爽肤水   99.0   \n",
       "3  2016/11/14  A18178033846  CHANDO/自然堂 男士劲爽控油洁面膏 100g 深层清洁  男士洗面奶   38.0   \n",
       "4  2016/11/14  A18178045259     CHANDO/自然堂雪域精粹纯粹滋润霜（清爽型）50g补水保湿滋润霜  139.0   \n",
       "\n",
       "   sale_count  comment_count   店名  \n",
       "0     26719.0         2704.0  自然堂  \n",
       "1      8122.0         1492.0  自然堂  \n",
       "2     12668.0          589.0  自然堂  \n",
       "3     25805.0         4287.0  自然堂  \n",
       "4      5196.0          618.0  自然堂  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "data2 = pd.read_csv('双十一淘宝美妆数据.csv')\n",
    "data2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "annoying-guidance",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 27598 entries, 0 to 27597\n",
      "Data columns (total 7 columns):\n",
      " #   Column         Non-Null Count  Dtype  \n",
      "---  ------         --------------  -----  \n",
      " 0   update_time    27598 non-null  object \n",
      " 1   id             27598 non-null  object \n",
      " 2   title          27598 non-null  object \n",
      " 3   price          27598 non-null  float64\n",
      " 4   sale_count     25244 non-null  float64\n",
      " 5   comment_count  25244 non-null  float64\n",
      " 6   店名             27598 non-null  object \n",
      "dtypes: float64(3), object(4)\n",
      "memory usage: 1.5+ MB\n"
     ]
    }
   ],
   "source": [
    "data2.info()  # 数据集情况 28010 条，6个字段"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "silent-taxation",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "update_time      86\n",
       "id               86\n",
       "title            86\n",
       "price            86\n",
       "sale_count       82\n",
       "comment_count    82\n",
       "店名               86\n",
       "dtype: int64"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data2[data2.duplicated()].count() # 有86条完全重复数据 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "neural-toner",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "update_time         0\n",
       "id                  0\n",
       "title               0\n",
       "price               0\n",
       "sale_count       2350\n",
       "comment_count    2350\n",
       "店名                  0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data2.drop_duplicates(inplace=True)   # 删除重复数据\n",
    "data2.reset_index(drop=True, inplace=True)  # 重建索引\n",
    "data2.isnull().sum()  # 查看空值 ，销售数量和评论数有空值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "binding-handle",
   "metadata": {},
   "outputs": [],
   "source": [
    "data2.fillna(0, inplace=True) # 空值填充\n",
    "data2['update_time'] = pd.to_datetime(data2['update_time']).apply(lambda x: x.strftime(\"%Y-%m-%d\")) # 日期格式化，便于统计"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "radio-verse",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>update_time</th>\n",
       "      <th>id</th>\n",
       "      <th>title</th>\n",
       "      <th>price</th>\n",
       "      <th>sale_count</th>\n",
       "      <th>comment_count</th>\n",
       "      <th>店名</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>27042</th>\n",
       "      <td>2016-11-05</td>\n",
       "      <td>A541190557158</td>\n",
       "      <td>Herborist/佰草集新美肌梦幻曲面贴膜3片 保湿补水</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>佰草集</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1494</th>\n",
       "      <td>2016-11-10</td>\n",
       "      <td>A538981087285</td>\n",
       "      <td>【双II预售】资生堂 新透白色控霜 30ml</td>\n",
       "      <td>390.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>资生堂</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24148</th>\n",
       "      <td>2016-11-09</td>\n",
       "      <td>A540190519057</td>\n",
       "      <td>【娇兰盛典】腮红亲密容和肌肤 裸妆感 自然持久玫瑰闰色腮红</td>\n",
       "      <td>420.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>娇兰</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24147</th>\n",
       "      <td>2016-11-09</td>\n",
       "      <td>A540189922026</td>\n",
       "      <td>【娇兰盛典】丝柔蜜粉饼 营造细致透明妆感 柔滑细腻贴肤美颜</td>\n",
       "      <td>480.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>娇兰</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16974</th>\n",
       "      <td>2016-11-05</td>\n",
       "      <td>A541166044768</td>\n",
       "      <td>L'OREAL欧莱雅卓韵霜时尚魅棕系列染发霜 富含炫闪因子蜜茶棕红棕</td>\n",
       "      <td>79.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>欧莱雅</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      update_time             id                               title  price  \\\n",
       "27042  2016-11-05  A541190557158       Herborist/佰草集新美肌梦幻曲面贴膜3片 保湿补水    1.0   \n",
       "1494   2016-11-10  A538981087285              【双II预售】资生堂 新透白色控霜 30ml  390.0   \n",
       "24148  2016-11-09  A540190519057       【娇兰盛典】腮红亲密容和肌肤 裸妆感 自然持久玫瑰闰色腮红  420.0   \n",
       "24147  2016-11-09  A540189922026       【娇兰盛典】丝柔蜜粉饼 营造细致透明妆感 柔滑细腻贴肤美颜  480.0   \n",
       "16974  2016-11-05  A541166044768  L'OREAL欧莱雅卓韵霜时尚魅棕系列染发霜 富含炫闪因子蜜茶棕红棕   79.0   \n",
       "\n",
       "       sale_count  comment_count   店名  \n",
       "27042         1.0            0.0  佰草集  \n",
       "1494          1.0            0.0  资生堂  \n",
       "24148         1.0            0.0   娇兰  \n",
       "24147         1.0            1.0   娇兰  \n",
       "16974         1.0            0.0  欧莱雅  "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data2[data2['sale_count']>0].sort_values(by=['sale_count']).head() # 从数据来看，sale_count 是销售量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "exterior-headquarters",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>update_time</th>\n",
       "      <th>id</th>\n",
       "      <th>title</th>\n",
       "      <th>price</th>\n",
       "      <th>sale_count</th>\n",
       "      <th>comment_count</th>\n",
       "      <th>店名</th>\n",
       "      <th>sale_amount</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>27042</th>\n",
       "      <td>2016-11-05</td>\n",
       "      <td>A541190557158</td>\n",
       "      <td>Herborist/佰草集新美肌梦幻曲面贴膜3片 保湿补水</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>佰草集</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1494</th>\n",
       "      <td>2016-11-10</td>\n",
       "      <td>A538981087285</td>\n",
       "      <td>【双II预售】资生堂 新透白色控霜 30ml</td>\n",
       "      <td>390.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>资生堂</td>\n",
       "      <td>390.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24148</th>\n",
       "      <td>2016-11-09</td>\n",
       "      <td>A540190519057</td>\n",
       "      <td>【娇兰盛典】腮红亲密容和肌肤 裸妆感 自然持久玫瑰闰色腮红</td>\n",
       "      <td>420.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>娇兰</td>\n",
       "      <td>420.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24147</th>\n",
       "      <td>2016-11-09</td>\n",
       "      <td>A540189922026</td>\n",
       "      <td>【娇兰盛典】丝柔蜜粉饼 营造细致透明妆感 柔滑细腻贴肤美颜</td>\n",
       "      <td>480.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>娇兰</td>\n",
       "      <td>480.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16974</th>\n",
       "      <td>2016-11-05</td>\n",
       "      <td>A541166044768</td>\n",
       "      <td>L'OREAL欧莱雅卓韵霜时尚魅棕系列染发霜 富含炫闪因子蜜茶棕红棕</td>\n",
       "      <td>79.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>欧莱雅</td>\n",
       "      <td>79.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17470</th>\n",
       "      <td>2016-11-10</td>\n",
       "      <td>A24304992630</td>\n",
       "      <td>德国妮维雅男士洗面奶控油祛痘印保湿去黑头去油清洁面乳液护肤品</td>\n",
       "      <td>42.0</td>\n",
       "      <td>1827562.0</td>\n",
       "      <td>200154.0</td>\n",
       "      <td>妮维雅</td>\n",
       "      <td>76757604.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17339</th>\n",
       "      <td>2016-11-11</td>\n",
       "      <td>A24304992630</td>\n",
       "      <td>2瓶更划算*妮维雅男士洗面奶控油祛痘印保湿去黑头去油洁面乳护肤</td>\n",
       "      <td>35.0</td>\n",
       "      <td>1886100.0</td>\n",
       "      <td>199532.0</td>\n",
       "      <td>妮维雅</td>\n",
       "      <td>66013500.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17228</th>\n",
       "      <td>2016-11-12</td>\n",
       "      <td>A24304992630</td>\n",
       "      <td>德国妮维雅男士洗面奶控油祛痘印保湿去黑头去油清洁面乳液护肤品</td>\n",
       "      <td>37.9</td>\n",
       "      <td>1920083.0</td>\n",
       "      <td>199062.0</td>\n",
       "      <td>妮维雅</td>\n",
       "      <td>72771145.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17126</th>\n",
       "      <td>2016-11-13</td>\n",
       "      <td>A24304992630</td>\n",
       "      <td>德国妮维雅男士洗面奶控油祛痘印保湿去黑头去油清洁面乳液护肤品</td>\n",
       "      <td>37.9</td>\n",
       "      <td>1921582.0</td>\n",
       "      <td>198774.0</td>\n",
       "      <td>妮维雅</td>\n",
       "      <td>72827957.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17026</th>\n",
       "      <td>2016-11-14</td>\n",
       "      <td>A24304992630</td>\n",
       "      <td>德国妮维雅男士洗面奶控油祛痘印保湿去黑头去油清洁面乳液护肤品</td>\n",
       "      <td>42.0</td>\n",
       "      <td>1923160.0</td>\n",
       "      <td>197949.0</td>\n",
       "      <td>妮维雅</td>\n",
       "      <td>80772720.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>24398 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      update_time             id                               title  price  \\\n",
       "27042  2016-11-05  A541190557158       Herborist/佰草集新美肌梦幻曲面贴膜3片 保湿补水    1.0   \n",
       "1494   2016-11-10  A538981087285              【双II预售】资生堂 新透白色控霜 30ml  390.0   \n",
       "24148  2016-11-09  A540190519057       【娇兰盛典】腮红亲密容和肌肤 裸妆感 自然持久玫瑰闰色腮红  420.0   \n",
       "24147  2016-11-09  A540189922026       【娇兰盛典】丝柔蜜粉饼 营造细致透明妆感 柔滑细腻贴肤美颜  480.0   \n",
       "16974  2016-11-05  A541166044768  L'OREAL欧莱雅卓韵霜时尚魅棕系列染发霜 富含炫闪因子蜜茶棕红棕   79.0   \n",
       "...           ...            ...                                 ...    ...   \n",
       "17470  2016-11-10   A24304992630      德国妮维雅男士洗面奶控油祛痘印保湿去黑头去油清洁面乳液护肤品   42.0   \n",
       "17339  2016-11-11   A24304992630     2瓶更划算*妮维雅男士洗面奶控油祛痘印保湿去黑头去油洁面乳护肤   35.0   \n",
       "17228  2016-11-12   A24304992630      德国妮维雅男士洗面奶控油祛痘印保湿去黑头去油清洁面乳液护肤品   37.9   \n",
       "17126  2016-11-13   A24304992630      德国妮维雅男士洗面奶控油祛痘印保湿去黑头去油清洁面乳液护肤品   37.9   \n",
       "17026  2016-11-14   A24304992630      德国妮维雅男士洗面奶控油祛痘印保湿去黑头去油清洁面乳液护肤品   42.0   \n",
       "\n",
       "       sale_count  comment_count   店名  sale_amount  \n",
       "27042         1.0            0.0  佰草集          1.0  \n",
       "1494          1.0            0.0  资生堂        390.0  \n",
       "24148         1.0            0.0   娇兰        420.0  \n",
       "24147         1.0            1.0   娇兰        480.0  \n",
       "16974         1.0            0.0  欧莱雅         79.0  \n",
       "...           ...            ...  ...          ...  \n",
       "17470   1827562.0       200154.0  妮维雅   76757604.0  \n",
       "17339   1886100.0       199532.0  妮维雅   66013500.0  \n",
       "17228   1920083.0       199062.0  妮维雅   72771145.7  \n",
       "17126   1921582.0       198774.0  妮维雅   72827957.8  \n",
       "17026   1923160.0       197949.0  妮维雅   80772720.0  \n",
       "\n",
       "[24398 rows x 8 columns]"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data2['sale_amount'] = data2['price'] * data2['sale_count']  # 增加一列销售额\n",
    "data2[data2['sale_count']>0].sort_values(by=['sale_count'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "supreme-performer",
   "metadata": {},
   "source": [
    "### 2、数据分析与可视化"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "traditional-third",
   "metadata": {},
   "source": [
    "#### 2.1 每日整体销售量走势"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "unnecessary-ownership",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"b915d3b0ff4046a981bfa285ab854e24\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_b915d3b0ff4046a981bfa285ab854e24 = echarts.init(\n",
       "                    document.getElementById('b915d3b0ff4046a981bfa285ab854e24'), 'white', {renderer: 'canvas'});\n",
       "                var option_b915d3b0ff4046a981bfa285ab854e24 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u9500\\u552e\\u91cf\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2016-11-05\",\n",
       "                    32021763.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2016-11-06\",\n",
       "                    32617979.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2016-11-07\",\n",
       "                    31596576.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2016-11-08\",\n",
       "                    32666229.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2016-11-09\",\n",
       "                    33323546.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2016-11-10\",\n",
       "                    31775729.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2016-11-11\",\n",
       "                    27818183.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2016-11-12\",\n",
       "                    28821197.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2016-11-13\",\n",
       "                    29301688.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2016-11-14\",\n",
       "                    29953666.0\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0.5\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5927\\u503c\",\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5c0f\\u503c\",\n",
       "                        \"type\": \"min\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u5e73\\u5747\\u503c\",\n",
       "                        \"type\": \"average\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0,\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u9500\\u552e\\u91cf\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u9500\\u552e\\u91cf\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2016-11-05\",\n",
       "                \"2016-11-06\",\n",
       "                \"2016-11-07\",\n",
       "                \"2016-11-08\",\n",
       "                \"2016-11-09\",\n",
       "                \"2016-11-10\",\n",
       "                \"2016-11-11\",\n",
       "                \"2016-11-12\",\n",
       "                \"2016-11-13\",\n",
       "                \"2016-11-14\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6bcf\\u65e5\\u6574\\u4f53\\u9500\\u552e\\u91cf\\u8d70\\u52bf\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_b915d3b0ff4046a981bfa285ab854e24.setOption(option_b915d3b0ff4046a981bfa285ab854e24);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1c77e7c91d0>"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result = data2.groupby('update_time').agg({'sale_count':'sum'}).to_dict()['sale_count']\n",
    "c = (\n",
    "    Line()\n",
    "    .add_xaxis(list(result.keys()))\n",
    "    .add_yaxis(\"销售量\", list(result.values()))\n",
    "    .set_series_opts(\n",
    "        areastyle_opts=opts.AreaStyleOpts(opacity=0.5),\n",
    "        label_opts=opts.LabelOpts(is_show=False),\n",
    "        markpoint_opts=opts.MarkPointOpts(\n",
    "            data=[\n",
    "                opts.MarkPointItem(type_=\"max\", name=\"最大值\"),\n",
    "                opts.MarkPointItem(type_=\"min\", name=\"最小值\"),\n",
    "                opts.MarkPointItem(type_=\"average\", name=\"平均值\"),\n",
    "            ]\n",
    "        ),\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"每日整体销售量走势\"))\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "technical-vitamin",
   "metadata": {},
   "source": [
    "#### 2.2 谁家的化妆品卖的最好"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "blessed-wagon",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['2016-11-05',\n",
       " '2016-11-06',\n",
       " '2016-11-07',\n",
       " '2016-11-08',\n",
       " '2016-11-09',\n",
       " '2016-11-10',\n",
       " '2016-11-11',\n",
       " '2016-11-12',\n",
       " '2016-11-13',\n",
       " '2016-11-14']"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dts = list(data2['update_time'].unique())\n",
    "dts.reverse()\n",
    "dts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "olive-accident",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"31b1855d502244f7a109787c9ae52104\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_31b1855d502244f7a109787c9ae52104 = echarts.init(\n",
       "                    document.getElementById('31b1855d502244f7a109787c9ae52104'), 'white', {renderer: 'canvas'});\n",
       "                var option_31b1855d502244f7a109787c9ae52104 = {\n",
       "    \"baseOption\": {\n",
       "        \"series\": [\n",
       "            {\n",
       "                \"type\": \"bar\",\n",
       "                \"name\": \"\\u9500\\u552e\\u91cf\",\n",
       "                \"legendHoverLink\": true,\n",
       "                \"data\": [\n",
       "                    882.59,\n",
       "                    913.02,\n",
       "                    1499.45,\n",
       "                    1539.12,\n",
       "                    1783.75,\n",
       "                    3377.32,\n",
       "                    3825.45,\n",
       "                    3907.05,\n",
       "                    3935.81,\n",
       "                    6546.29\n",
       "                ],\n",
       "                \"showBackground\": false,\n",
       "                \"barMinHeight\": 0,\n",
       "                \"barCategoryGap\": \"20%\",\n",
       "                \"barGap\": \"30%\",\n",
       "                \"large\": false,\n",
       "                \"largeThreshold\": 400,\n",
       "                \"seriesLayoutBy\": \"column\",\n",
       "                \"datasetIndex\": 0,\n",
       "                \"clip\": true,\n",
       "                \"zlevel\": 0,\n",
       "                \"z\": 2,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"right\",\n",
       "                    \"margin\": 8,\n",
       "                    \"formatter\": \"{@[1]/} \\u4e07\"\n",
       "                }\n",
       "            },\n",
       "            {\n",
       "                \"type\": \"bar\",\n",
       "                \"name\": \"\\u9500\\u552e\\u989d\",\n",
       "                \"legendHoverLink\": true,\n",
       "                \"data\": [\n",
       "                    3.85,\n",
       "                    25.26,\n",
       "                    40.19,\n",
       "                    20.82,\n",
       "                    29.41,\n",
       "                    53.12,\n",
       "                    22.0,\n",
       "                    33.87,\n",
       "                    35.32,\n",
       "                    61.46\n",
       "                ],\n",
       "                \"showBackground\": false,\n",
       "                \"barMinHeight\": 0,\n",
       "                \"barCategoryGap\": \"20%\",\n",
       "                \"barGap\": \"30%\",\n",
       "                \"large\": false,\n",
       "                \"largeThreshold\": 400,\n",
       "                \"seriesLayoutBy\": \"column\",\n",
       "                \"datasetIndex\": 0,\n",
       "                \"clip\": true,\n",
       "                \"zlevel\": 0,\n",
       "                \"z\": 2,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"right\",\n",
       "                    \"margin\": 8,\n",
       "                    \"formatter\": \"{@[1]/} \\u4ebf\\u5143\"\n",
       "                }\n",
       "            }\n",
       "        ],\n",
       "        \"timeline\": {\n",
       "            \"axisType\": \"category\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"autoPlay\": false,\n",
       "            \"controlPosition\": \"left\",\n",
       "            \"loop\": false,\n",
       "            \"rewind\": false,\n",
       "            \"show\": true,\n",
       "            \"inverse\": false,\n",
       "            \"playInterval\": 500,\n",
       "            \"bottom\": \"-5px\",\n",
       "            \"data\": [\n",
       "                \"2016-11-05\",\n",
       "                \"2016-11-06\",\n",
       "                \"2016-11-07\",\n",
       "                \"2016-11-08\",\n",
       "                \"2016-11-09\",\n",
       "                \"2016-11-10\",\n",
       "                \"2016-11-11\",\n",
       "                \"2016-11-12\",\n",
       "                \"2016-11-13\",\n",
       "                \"2016-11-14\"\n",
       "            ]\n",
       "        },\n",
       "        \"xAxis\": [\n",
       "            {\n",
       "                \"show\": true,\n",
       "                \"scale\": false,\n",
       "                \"nameLocation\": \"end\",\n",
       "                \"nameGap\": 15,\n",
       "                \"gridIndex\": 0,\n",
       "                \"inverse\": false,\n",
       "                \"offset\": 0,\n",
       "                \"splitNumber\": 5,\n",
       "                \"minInterval\": 0,\n",
       "                \"splitLine\": {\n",
       "                    \"show\": false,\n",
       "                    \"lineStyle\": {\n",
       "                        \"show\": true,\n",
       "                        \"width\": 1,\n",
       "                        \"opacity\": 1,\n",
       "                        \"curveness\": 0,\n",
       "                        \"type\": \"solid\"\n",
       "                    }\n",
       "                }\n",
       "            }\n",
       "        ],\n",
       "        \"yAxis\": [\n",
       "            {\n",
       "                \"show\": true,\n",
       "                \"scale\": false,\n",
       "                \"nameLocation\": \"end\",\n",
       "                \"nameGap\": 15,\n",
       "                \"gridIndex\": 0,\n",
       "                \"inverse\": false,\n",
       "                \"offset\": 0,\n",
       "                \"splitNumber\": 5,\n",
       "                \"minInterval\": 0,\n",
       "                \"splitLine\": {\n",
       "                    \"show\": false,\n",
       "                    \"lineStyle\": {\n",
       "                        \"show\": true,\n",
       "                        \"width\": 1,\n",
       "                        \"opacity\": 1,\n",
       "                        \"curveness\": 0,\n",
       "                        \"type\": \"solid\"\n",
       "                    }\n",
       "                },\n",
       "                \"data\": [\n",
       "                    \"\\u7f8e\\u52a0\\u51c0\",\n",
       "                    \"\\u5170\\u829d\",\n",
       "                    \"\\u4f70\\u8349\\u96c6\",\n",
       "                    \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                    \"\\u81ea\\u7136\\u5802\",\n",
       "                    \"\\u6b27\\u83b1\\u96c5\",\n",
       "                    \"\\u59ae\\u7ef4\\u96c5\",\n",
       "                    \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                    \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                    \"\\u76f8\\u5b9c\\u672c\\u8349\"\n",
       "                ]\n",
       "            }\n",
       "        ]\n",
       "    },\n",
       "    \"options\": [\n",
       "        {\n",
       "            \"legend\": [\n",
       "                {\n",
       "                    \"data\": [\n",
       "                        \"\\u9500\\u552e\\u91cf\",\n",
       "                        \"\\u9500\\u552e\\u989d\"\n",
       "                    ],\n",
       "                    \"selected\": {\n",
       "                        \"\\u9500\\u552e\\u91cf\": true,\n",
       "                        \"\\u9500\\u552e\\u989d\": true\n",
       "                    },\n",
       "                    \"show\": true,\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10,\n",
       "                    \"itemWidth\": 25,\n",
       "                    \"itemHeight\": 14\n",
       "                }\n",
       "            ],\n",
       "            \"series\": [\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u91cf\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        89.51,\n",
       "                        101.49,\n",
       "                        143.79,\n",
       "                        152.7,\n",
       "                        153.77,\n",
       "                        262.64,\n",
       "                        397.24,\n",
       "                        398.33,\n",
       "                        409.06,\n",
       "                        785.77\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4e07\"\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u989d\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        0.39,\n",
       "                        2.81,\n",
       "                        4.07,\n",
       "                        2.14,\n",
       "                        2.74,\n",
       "                        4.53,\n",
       "                        2.33,\n",
       "                        3.47,\n",
       "                        3.65,\n",
       "                        7.33\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4ebf\\u5143\"\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"xAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"yAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    },\n",
       "                    \"data\": [\n",
       "                        \"\\u7f8e\\u52a0\\u51c0\",\n",
       "                        \"\\u5170\\u829d\",\n",
       "                        \"\\u4f70\\u8349\\u96c6\",\n",
       "                        \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                        \"\\u81ea\\u7136\\u5802\",\n",
       "                        \"\\u6b27\\u83b1\\u96c5\",\n",
       "                        \"\\u59ae\\u7ef4\\u96c5\",\n",
       "                        \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                        \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                        \"\\u76f8\\u5b9c\\u672c\\u8349\"\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"title\": [\n",
       "                {\n",
       "                    \"text\": \"\\u7d2f\\u8ba1\\u9500\\u552e\\u91cf\\u6392\\u884c TOP10\",\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10\n",
       "                }\n",
       "            ],\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"color\": [\n",
       "                \"#c23531\",\n",
       "                \"#2f4554\",\n",
       "                \"#61a0a8\",\n",
       "                \"#d48265\",\n",
       "                \"#749f83\",\n",
       "                \"#ca8622\",\n",
       "                \"#bda29a\",\n",
       "                \"#6e7074\",\n",
       "                \"#546570\",\n",
       "                \"#c4ccd3\",\n",
       "                \"#f05b72\",\n",
       "                \"#ef5b9c\",\n",
       "                \"#f47920\",\n",
       "                \"#905a3d\",\n",
       "                \"#fab27b\",\n",
       "                \"#2a5caa\",\n",
       "                \"#444693\",\n",
       "                \"#726930\",\n",
       "                \"#b2d235\",\n",
       "                \"#6d8346\",\n",
       "                \"#ac6767\",\n",
       "                \"#1d953f\",\n",
       "                \"#6950a1\",\n",
       "                \"#918597\"\n",
       "            ]\n",
       "        },\n",
       "        {\n",
       "            \"legend\": [\n",
       "                {\n",
       "                    \"data\": [\n",
       "                        \"\\u9500\\u552e\\u91cf\",\n",
       "                        \"\\u9500\\u552e\\u989d\"\n",
       "                    ],\n",
       "                    \"selected\": {\n",
       "                        \"\\u9500\\u552e\\u91cf\": true,\n",
       "                        \"\\u9500\\u552e\\u989d\": true\n",
       "                    },\n",
       "                    \"show\": true,\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10,\n",
       "                    \"itemWidth\": 25,\n",
       "                    \"itemHeight\": 14\n",
       "                }\n",
       "            ],\n",
       "            \"series\": [\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u91cf\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        178.14,\n",
       "                        203.17,\n",
       "                        287.76,\n",
       "                        305.56,\n",
       "                        307.57,\n",
       "                        583.83,\n",
       "                        795.19,\n",
       "                        798.69,\n",
       "                        818.48,\n",
       "                        1571.45\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4e07\"\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u989d\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        0.77,\n",
       "                        5.61,\n",
       "                        8.15,\n",
       "                        4.28,\n",
       "                        5.49,\n",
       "                        10.09,\n",
       "                        4.67,\n",
       "                        6.96,\n",
       "                        7.31,\n",
       "                        14.65\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4ebf\\u5143\"\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"xAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"yAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    },\n",
       "                    \"data\": [\n",
       "                        \"\\u7f8e\\u52a0\\u51c0\",\n",
       "                        \"\\u5170\\u829d\",\n",
       "                        \"\\u4f70\\u8349\\u96c6\",\n",
       "                        \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                        \"\\u81ea\\u7136\\u5802\",\n",
       "                        \"\\u6b27\\u83b1\\u96c5\",\n",
       "                        \"\\u59ae\\u7ef4\\u96c5\",\n",
       "                        \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                        \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                        \"\\u76f8\\u5b9c\\u672c\\u8349\"\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"title\": [\n",
       "                {\n",
       "                    \"text\": \"\\u7d2f\\u8ba1\\u9500\\u552e\\u91cf\\u6392\\u884c TOP10\",\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10\n",
       "                }\n",
       "            ],\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"color\": [\n",
       "                \"#c23531\",\n",
       "                \"#2f4554\",\n",
       "                \"#61a0a8\",\n",
       "                \"#d48265\",\n",
       "                \"#749f83\",\n",
       "                \"#ca8622\",\n",
       "                \"#bda29a\",\n",
       "                \"#6e7074\",\n",
       "                \"#546570\",\n",
       "                \"#c4ccd3\",\n",
       "                \"#f05b72\",\n",
       "                \"#ef5b9c\",\n",
       "                \"#f47920\",\n",
       "                \"#905a3d\",\n",
       "                \"#fab27b\",\n",
       "                \"#2a5caa\",\n",
       "                \"#444693\",\n",
       "                \"#726930\",\n",
       "                \"#b2d235\",\n",
       "                \"#6d8346\",\n",
       "                \"#ac6767\",\n",
       "                \"#1d953f\",\n",
       "                \"#6950a1\",\n",
       "                \"#918597\"\n",
       "            ]\n",
       "        },\n",
       "        {\n",
       "            \"legend\": [\n",
       "                {\n",
       "                    \"data\": [\n",
       "                        \"\\u9500\\u552e\\u91cf\",\n",
       "                        \"\\u9500\\u552e\\u989d\"\n",
       "                    ],\n",
       "                    \"selected\": {\n",
       "                        \"\\u9500\\u552e\\u91cf\": true,\n",
       "                        \"\\u9500\\u552e\\u989d\": true\n",
       "                    },\n",
       "                    \"show\": true,\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10,\n",
       "                    \"itemWidth\": 25,\n",
       "                    \"itemHeight\": 14\n",
       "                }\n",
       "            ],\n",
       "            \"series\": [\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u91cf\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        266.95,\n",
       "                        301.92,\n",
       "                        425.71,\n",
       "                        432.36,\n",
       "                        458.24,\n",
       "                        896.64,\n",
       "                        1142.82,\n",
       "                        1200.21,\n",
       "                        1228.24,\n",
       "                        2342.49\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4e07\"\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u989d\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        1.16,\n",
       "                        8.37,\n",
       "                        7.44,\n",
       "                        12.24,\n",
       "                        6.42,\n",
       "                        15.6,\n",
       "                        6.78,\n",
       "                        10.46,\n",
       "                        10.98,\n",
       "                        21.93\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4ebf\\u5143\"\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"xAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"yAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    },\n",
       "                    \"data\": [\n",
       "                        \"\\u7f8e\\u52a0\\u51c0\",\n",
       "                        \"\\u5170\\u829d\",\n",
       "                        \"\\u81ea\\u7136\\u5802\",\n",
       "                        \"\\u4f70\\u8349\\u96c6\",\n",
       "                        \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                        \"\\u6b27\\u83b1\\u96c5\",\n",
       "                        \"\\u59ae\\u7ef4\\u96c5\",\n",
       "                        \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                        \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                        \"\\u76f8\\u5b9c\\u672c\\u8349\"\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"title\": [\n",
       "                {\n",
       "                    \"text\": \"\\u7d2f\\u8ba1\\u9500\\u552e\\u91cf\\u6392\\u884c TOP10\",\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10\n",
       "                }\n",
       "            ],\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"color\": [\n",
       "                \"#c23531\",\n",
       "                \"#2f4554\",\n",
       "                \"#61a0a8\",\n",
       "                \"#d48265\",\n",
       "                \"#749f83\",\n",
       "                \"#ca8622\",\n",
       "                \"#bda29a\",\n",
       "                \"#6e7074\",\n",
       "                \"#546570\",\n",
       "                \"#c4ccd3\",\n",
       "                \"#f05b72\",\n",
       "                \"#ef5b9c\",\n",
       "                \"#f47920\",\n",
       "                \"#905a3d\",\n",
       "                \"#fab27b\",\n",
       "                \"#2a5caa\",\n",
       "                \"#444693\",\n",
       "                \"#726930\",\n",
       "                \"#b2d235\",\n",
       "                \"#6d8346\",\n",
       "                \"#ac6767\",\n",
       "                \"#1d953f\",\n",
       "                \"#6950a1\",\n",
       "                \"#918597\"\n",
       "            ]\n",
       "        },\n",
       "        {\n",
       "            \"legend\": [\n",
       "                {\n",
       "                    \"data\": [\n",
       "                        \"\\u9500\\u552e\\u91cf\",\n",
       "                        \"\\u9500\\u552e\\u989d\"\n",
       "                    ],\n",
       "                    \"selected\": {\n",
       "                        \"\\u9500\\u552e\\u91cf\": true,\n",
       "                        \"\\u9500\\u552e\\u989d\": true\n",
       "                    },\n",
       "                    \"show\": true,\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10,\n",
       "                    \"itemWidth\": 25,\n",
       "                    \"itemHeight\": 14\n",
       "                }\n",
       "            ],\n",
       "            \"series\": [\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u91cf\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        355.36,\n",
       "                        399.73,\n",
       "                        576.19,\n",
       "                        582.07,\n",
       "                        611.1,\n",
       "                        1225.65,\n",
       "                        1542.12,\n",
       "                        1602.35,\n",
       "                        1638.46,\n",
       "                        3113.66\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4e07\"\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u989d\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        1.53,\n",
       "                        11.11,\n",
       "                        16.28,\n",
       "                        10.23,\n",
       "                        8.56,\n",
       "                        21.28,\n",
       "                        9.13,\n",
       "                        13.97,\n",
       "                        14.64,\n",
       "                        29.22\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4ebf\\u5143\"\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"xAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"yAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    },\n",
       "                    \"data\": [\n",
       "                        \"\\u7f8e\\u52a0\\u51c0\",\n",
       "                        \"\\u5170\\u829d\",\n",
       "                        \"\\u4f70\\u8349\\u96c6\",\n",
       "                        \"\\u81ea\\u7136\\u5802\",\n",
       "                        \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                        \"\\u6b27\\u83b1\\u96c5\",\n",
       "                        \"\\u59ae\\u7ef4\\u96c5\",\n",
       "                        \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                        \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                        \"\\u76f8\\u5b9c\\u672c\\u8349\"\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"title\": [\n",
       "                {\n",
       "                    \"text\": \"\\u7d2f\\u8ba1\\u9500\\u552e\\u91cf\\u6392\\u884c TOP10\",\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10\n",
       "                }\n",
       "            ],\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"color\": [\n",
       "                \"#c23531\",\n",
       "                \"#2f4554\",\n",
       "                \"#61a0a8\",\n",
       "                \"#d48265\",\n",
       "                \"#749f83\",\n",
       "                \"#ca8622\",\n",
       "                \"#bda29a\",\n",
       "                \"#6e7074\",\n",
       "                \"#546570\",\n",
       "                \"#c4ccd3\",\n",
       "                \"#f05b72\",\n",
       "                \"#ef5b9c\",\n",
       "                \"#f47920\",\n",
       "                \"#905a3d\",\n",
       "                \"#fab27b\",\n",
       "                \"#2a5caa\",\n",
       "                \"#444693\",\n",
       "                \"#726930\",\n",
       "                \"#b2d235\",\n",
       "                \"#6d8346\",\n",
       "                \"#ac6767\",\n",
       "                \"#1d953f\",\n",
       "                \"#6950a1\",\n",
       "                \"#918597\"\n",
       "            ]\n",
       "        },\n",
       "        {\n",
       "            \"legend\": [\n",
       "                {\n",
       "                    \"data\": [\n",
       "                        \"\\u9500\\u552e\\u91cf\",\n",
       "                        \"\\u9500\\u552e\\u989d\"\n",
       "                    ],\n",
       "                    \"selected\": {\n",
       "                        \"\\u9500\\u552e\\u91cf\": true,\n",
       "                        \"\\u9500\\u552e\\u989d\": true\n",
       "                    },\n",
       "                    \"show\": true,\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10,\n",
       "                    \"itemWidth\": 25,\n",
       "                    \"itemHeight\": 14\n",
       "                }\n",
       "            ],\n",
       "            \"series\": [\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u91cf\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        446.1,\n",
       "                        497.76,\n",
       "                        721.08,\n",
       "                        739.42,\n",
       "                        763.95,\n",
       "                        1602.31,\n",
       "                        1942.14,\n",
       "                        2010.29,\n",
       "                        2049.46,\n",
       "                        3885.0\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4e07\"\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u989d\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        1.92,\n",
       "                        13.87,\n",
       "                        20.33,\n",
       "                        13.03,\n",
       "                        10.7,\n",
       "                        27.26,\n",
       "                        11.48,\n",
       "                        17.55,\n",
       "                        18.31,\n",
       "                        36.51\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4ebf\\u5143\"\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"xAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"yAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    },\n",
       "                    \"data\": [\n",
       "                        \"\\u7f8e\\u52a0\\u51c0\",\n",
       "                        \"\\u5170\\u829d\",\n",
       "                        \"\\u4f70\\u8349\\u96c6\",\n",
       "                        \"\\u81ea\\u7136\\u5802\",\n",
       "                        \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                        \"\\u6b27\\u83b1\\u96c5\",\n",
       "                        \"\\u59ae\\u7ef4\\u96c5\",\n",
       "                        \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                        \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                        \"\\u76f8\\u5b9c\\u672c\\u8349\"\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"title\": [\n",
       "                {\n",
       "                    \"text\": \"\\u7d2f\\u8ba1\\u9500\\u552e\\u91cf\\u6392\\u884c TOP10\",\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10\n",
       "                }\n",
       "            ],\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"color\": [\n",
       "                \"#c23531\",\n",
       "                \"#2f4554\",\n",
       "                \"#61a0a8\",\n",
       "                \"#d48265\",\n",
       "                \"#749f83\",\n",
       "                \"#ca8622\",\n",
       "                \"#bda29a\",\n",
       "                \"#6e7074\",\n",
       "                \"#546570\",\n",
       "                \"#c4ccd3\",\n",
       "                \"#f05b72\",\n",
       "                \"#ef5b9c\",\n",
       "                \"#f47920\",\n",
       "                \"#905a3d\",\n",
       "                \"#fab27b\",\n",
       "                \"#2a5caa\",\n",
       "                \"#444693\",\n",
       "                \"#726930\",\n",
       "                \"#b2d235\",\n",
       "                \"#6d8346\",\n",
       "                \"#ac6767\",\n",
       "                \"#1d953f\",\n",
       "                \"#6950a1\",\n",
       "                \"#918597\"\n",
       "            ]\n",
       "        },\n",
       "        {\n",
       "            \"legend\": [\n",
       "                {\n",
       "                    \"data\": [\n",
       "                        \"\\u9500\\u552e\\u91cf\",\n",
       "                        \"\\u9500\\u552e\\u989d\"\n",
       "                    ],\n",
       "                    \"selected\": {\n",
       "                        \"\\u9500\\u552e\\u91cf\": true,\n",
       "                        \"\\u9500\\u552e\\u989d\": true\n",
       "                    },\n",
       "                    \"show\": true,\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10,\n",
       "                    \"itemWidth\": 25,\n",
       "                    \"itemHeight\": 14\n",
       "                }\n",
       "            ],\n",
       "            \"series\": [\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u91cf\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        536.88,\n",
       "                        597.37,\n",
       "                        866.21,\n",
       "                        896.79,\n",
       "                        917.02,\n",
       "                        1993.09,\n",
       "                        2346.7,\n",
       "                        2420.14,\n",
       "                        2461.36,\n",
       "                        4475.64\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4e07\"\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u989d\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        2.33,\n",
       "                        16.67,\n",
       "                        24.38,\n",
       "                        15.84,\n",
       "                        12.84,\n",
       "                        33.56,\n",
       "                        13.89,\n",
       "                        21.15,\n",
       "                        22.02,\n",
       "                        43.06\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4ebf\\u5143\"\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"xAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"yAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    },\n",
       "                    \"data\": [\n",
       "                        \"\\u7f8e\\u52a0\\u51c0\",\n",
       "                        \"\\u5170\\u829d\",\n",
       "                        \"\\u4f70\\u8349\\u96c6\",\n",
       "                        \"\\u81ea\\u7136\\u5802\",\n",
       "                        \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                        \"\\u6b27\\u83b1\\u96c5\",\n",
       "                        \"\\u59ae\\u7ef4\\u96c5\",\n",
       "                        \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                        \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                        \"\\u76f8\\u5b9c\\u672c\\u8349\"\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"title\": [\n",
       "                {\n",
       "                    \"text\": \"\\u7d2f\\u8ba1\\u9500\\u552e\\u91cf\\u6392\\u884c TOP10\",\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10\n",
       "                }\n",
       "            ],\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"color\": [\n",
       "                \"#c23531\",\n",
       "                \"#2f4554\",\n",
       "                \"#61a0a8\",\n",
       "                \"#d48265\",\n",
       "                \"#749f83\",\n",
       "                \"#ca8622\",\n",
       "                \"#bda29a\",\n",
       "                \"#6e7074\",\n",
       "                \"#546570\",\n",
       "                \"#c4ccd3\",\n",
       "                \"#f05b72\",\n",
       "                \"#ef5b9c\",\n",
       "                \"#f47920\",\n",
       "                \"#905a3d\",\n",
       "                \"#fab27b\",\n",
       "                \"#2a5caa\",\n",
       "                \"#444693\",\n",
       "                \"#726930\",\n",
       "                \"#b2d235\",\n",
       "                \"#6d8346\",\n",
       "                \"#ac6767\",\n",
       "                \"#1d953f\",\n",
       "                \"#6950a1\",\n",
       "                \"#918597\"\n",
       "            ]\n",
       "        },\n",
       "        {\n",
       "            \"legend\": [\n",
       "                {\n",
       "                    \"data\": [\n",
       "                        \"\\u9500\\u552e\\u91cf\",\n",
       "                        \"\\u9500\\u552e\\u989d\"\n",
       "                    ],\n",
       "                    \"selected\": {\n",
       "                        \"\\u9500\\u552e\\u91cf\": true,\n",
       "                        \"\\u9500\\u552e\\u989d\": true\n",
       "                    },\n",
       "                    \"show\": true,\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10,\n",
       "                    \"itemWidth\": 25,\n",
       "                    \"itemHeight\": 14\n",
       "                }\n",
       "            ],\n",
       "            \"series\": [\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u91cf\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        604.91,\n",
       "                        685.45,\n",
       "                        1041.29,\n",
       "                        1069.45,\n",
       "                        1073.35,\n",
       "                        2323.66,\n",
       "                        2738.09,\n",
       "                        2807.01,\n",
       "                        2838.05,\n",
       "                        4870.87\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4e07\"\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u989d\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        2.64,\n",
       "                        19.23,\n",
       "                        27.05,\n",
       "                        18.07,\n",
       "                        14.72,\n",
       "                        37.93,\n",
       "                        15.92,\n",
       "                        24.38,\n",
       "                        25.16,\n",
       "                        46.19\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4ebf\\u5143\"\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"xAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"yAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    },\n",
       "                    \"data\": [\n",
       "                        \"\\u7f8e\\u52a0\\u51c0\",\n",
       "                        \"\\u5170\\u829d\",\n",
       "                        \"\\u4f70\\u8349\\u96c6\",\n",
       "                        \"\\u81ea\\u7136\\u5802\",\n",
       "                        \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                        \"\\u6b27\\u83b1\\u96c5\",\n",
       "                        \"\\u59ae\\u7ef4\\u96c5\",\n",
       "                        \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                        \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                        \"\\u76f8\\u5b9c\\u672c\\u8349\"\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"title\": [\n",
       "                {\n",
       "                    \"text\": \"\\u7d2f\\u8ba1\\u9500\\u552e\\u91cf\\u6392\\u884c TOP10\",\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10\n",
       "                }\n",
       "            ],\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"color\": [\n",
       "                \"#c23531\",\n",
       "                \"#2f4554\",\n",
       "                \"#61a0a8\",\n",
       "                \"#d48265\",\n",
       "                \"#749f83\",\n",
       "                \"#ca8622\",\n",
       "                \"#bda29a\",\n",
       "                \"#6e7074\",\n",
       "                \"#546570\",\n",
       "                \"#c4ccd3\",\n",
       "                \"#f05b72\",\n",
       "                \"#ef5b9c\",\n",
       "                \"#f47920\",\n",
       "                \"#905a3d\",\n",
       "                \"#fab27b\",\n",
       "                \"#2a5caa\",\n",
       "                \"#444693\",\n",
       "                \"#726930\",\n",
       "                \"#b2d235\",\n",
       "                \"#6d8346\",\n",
       "                \"#ac6767\",\n",
       "                \"#1d953f\",\n",
       "                \"#6950a1\",\n",
       "                \"#918597\"\n",
       "            ]\n",
       "        },\n",
       "        {\n",
       "            \"legend\": [\n",
       "                {\n",
       "                    \"data\": [\n",
       "                        \"\\u9500\\u552e\\u91cf\",\n",
       "                        \"\\u9500\\u552e\\u989d\"\n",
       "                    ],\n",
       "                    \"selected\": {\n",
       "                        \"\\u9500\\u552e\\u91cf\": true,\n",
       "                        \"\\u9500\\u552e\\u989d\": true\n",
       "                    },\n",
       "                    \"show\": true,\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10,\n",
       "                    \"itemWidth\": 25,\n",
       "                    \"itemHeight\": 14\n",
       "                }\n",
       "            ],\n",
       "            \"series\": [\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u91cf\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        697.48,\n",
       "                        762.49,\n",
       "                        1190.14,\n",
       "                        1228.88,\n",
       "                        1257.16,\n",
       "                        2676.23,\n",
       "                        3101.89,\n",
       "                        3173.53,\n",
       "                        3204.26,\n",
       "                        5423.64\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4e07\"\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u989d\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        3.05,\n",
       "                        21.27,\n",
       "                        31.43,\n",
       "                        16.76,\n",
       "                        21.34,\n",
       "                        42.93,\n",
       "                        17.89,\n",
       "                        27.54,\n",
       "                        28.48,\n",
       "                        51.21\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4ebf\\u5143\"\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"xAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"yAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    },\n",
       "                    \"data\": [\n",
       "                        \"\\u7f8e\\u52a0\\u51c0\",\n",
       "                        \"\\u5170\\u829d\",\n",
       "                        \"\\u4f70\\u8349\\u96c6\",\n",
       "                        \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                        \"\\u81ea\\u7136\\u5802\",\n",
       "                        \"\\u6b27\\u83b1\\u96c5\",\n",
       "                        \"\\u59ae\\u7ef4\\u96c5\",\n",
       "                        \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                        \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                        \"\\u76f8\\u5b9c\\u672c\\u8349\"\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"title\": [\n",
       "                {\n",
       "                    \"text\": \"\\u7d2f\\u8ba1\\u9500\\u552e\\u91cf\\u6392\\u884c TOP10\",\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10\n",
       "                }\n",
       "            ],\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"color\": [\n",
       "                \"#c23531\",\n",
       "                \"#2f4554\",\n",
       "                \"#61a0a8\",\n",
       "                \"#d48265\",\n",
       "                \"#749f83\",\n",
       "                \"#ca8622\",\n",
       "                \"#bda29a\",\n",
       "                \"#6e7074\",\n",
       "                \"#546570\",\n",
       "                \"#c4ccd3\",\n",
       "                \"#f05b72\",\n",
       "                \"#ef5b9c\",\n",
       "                \"#f47920\",\n",
       "                \"#905a3d\",\n",
       "                \"#fab27b\",\n",
       "                \"#2a5caa\",\n",
       "                \"#444693\",\n",
       "                \"#726930\",\n",
       "                \"#b2d235\",\n",
       "                \"#6d8346\",\n",
       "                \"#ac6767\",\n",
       "                \"#1d953f\",\n",
       "                \"#6950a1\",\n",
       "                \"#918597\"\n",
       "            ]\n",
       "        },\n",
       "        {\n",
       "            \"legend\": [\n",
       "                {\n",
       "                    \"data\": [\n",
       "                        \"\\u9500\\u552e\\u91cf\",\n",
       "                        \"\\u9500\\u552e\\u989d\"\n",
       "                    ],\n",
       "                    \"selected\": {\n",
       "                        \"\\u9500\\u552e\\u91cf\": true,\n",
       "                        \"\\u9500\\u552e\\u989d\": true\n",
       "                    },\n",
       "                    \"show\": true,\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10,\n",
       "                    \"itemWidth\": 25,\n",
       "                    \"itemHeight\": 14\n",
       "                }\n",
       "            ],\n",
       "            \"series\": [\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u91cf\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        790.08,\n",
       "                        837.72,\n",
       "                        1334.23,\n",
       "                        1383.97,\n",
       "                        1520.78,\n",
       "                        3028.02,\n",
       "                        3463.47,\n",
       "                        3540.21,\n",
       "                        3569.93,\n",
       "                        5963.06\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4e07\"\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u989d\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        3.45,\n",
       "                        23.26,\n",
       "                        35.74,\n",
       "                        18.79,\n",
       "                        25.35,\n",
       "                        47.91,\n",
       "                        19.88,\n",
       "                        30.71,\n",
       "                        31.77,\n",
       "                        56.1\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4ebf\\u5143\"\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"xAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"yAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    },\n",
       "                    \"data\": [\n",
       "                        \"\\u7f8e\\u52a0\\u51c0\",\n",
       "                        \"\\u5170\\u829d\",\n",
       "                        \"\\u4f70\\u8349\\u96c6\",\n",
       "                        \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                        \"\\u81ea\\u7136\\u5802\",\n",
       "                        \"\\u6b27\\u83b1\\u96c5\",\n",
       "                        \"\\u59ae\\u7ef4\\u96c5\",\n",
       "                        \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                        \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                        \"\\u76f8\\u5b9c\\u672c\\u8349\"\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"title\": [\n",
       "                {\n",
       "                    \"text\": \"\\u7d2f\\u8ba1\\u9500\\u552e\\u91cf\\u6392\\u884c TOP10\",\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10\n",
       "                }\n",
       "            ],\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"color\": [\n",
       "                \"#c23531\",\n",
       "                \"#2f4554\",\n",
       "                \"#61a0a8\",\n",
       "                \"#d48265\",\n",
       "                \"#749f83\",\n",
       "                \"#ca8622\",\n",
       "                \"#bda29a\",\n",
       "                \"#6e7074\",\n",
       "                \"#546570\",\n",
       "                \"#c4ccd3\",\n",
       "                \"#f05b72\",\n",
       "                \"#ef5b9c\",\n",
       "                \"#f47920\",\n",
       "                \"#905a3d\",\n",
       "                \"#fab27b\",\n",
       "                \"#2a5caa\",\n",
       "                \"#444693\",\n",
       "                \"#726930\",\n",
       "                \"#b2d235\",\n",
       "                \"#6d8346\",\n",
       "                \"#ac6767\",\n",
       "                \"#1d953f\",\n",
       "                \"#6950a1\",\n",
       "                \"#918597\"\n",
       "            ]\n",
       "        },\n",
       "        {\n",
       "            \"legend\": [\n",
       "                {\n",
       "                    \"data\": [\n",
       "                        \"\\u9500\\u552e\\u91cf\",\n",
       "                        \"\\u9500\\u552e\\u989d\"\n",
       "                    ],\n",
       "                    \"selected\": {\n",
       "                        \"\\u9500\\u552e\\u91cf\": true,\n",
       "                        \"\\u9500\\u552e\\u989d\": true\n",
       "                    },\n",
       "                    \"show\": true,\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10,\n",
       "                    \"itemWidth\": 25,\n",
       "                    \"itemHeight\": 14\n",
       "                }\n",
       "            ],\n",
       "            \"series\": [\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u91cf\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        882.59,\n",
       "                        913.02,\n",
       "                        1499.45,\n",
       "                        1539.12,\n",
       "                        1783.75,\n",
       "                        3377.32,\n",
       "                        3825.45,\n",
       "                        3907.05,\n",
       "                        3935.81,\n",
       "                        6546.29\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4e07\"\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"type\": \"bar\",\n",
       "                    \"name\": \"\\u9500\\u552e\\u989d\",\n",
       "                    \"legendHoverLink\": true,\n",
       "                    \"data\": [\n",
       "                        3.85,\n",
       "                        25.26,\n",
       "                        40.19,\n",
       "                        20.82,\n",
       "                        29.41,\n",
       "                        53.12,\n",
       "                        22.0,\n",
       "                        33.87,\n",
       "                        35.32,\n",
       "                        61.46\n",
       "                    ],\n",
       "                    \"showBackground\": false,\n",
       "                    \"barMinHeight\": 0,\n",
       "                    \"barCategoryGap\": \"20%\",\n",
       "                    \"barGap\": \"30%\",\n",
       "                    \"large\": false,\n",
       "                    \"largeThreshold\": 400,\n",
       "                    \"seriesLayoutBy\": \"column\",\n",
       "                    \"datasetIndex\": 0,\n",
       "                    \"clip\": true,\n",
       "                    \"zlevel\": 0,\n",
       "                    \"z\": 2,\n",
       "                    \"label\": {\n",
       "                        \"show\": true,\n",
       "                        \"position\": \"right\",\n",
       "                        \"margin\": 8,\n",
       "                        \"formatter\": \"{@[1]/} \\u4ebf\\u5143\"\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"xAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"yAxis\": [\n",
       "                {\n",
       "                    \"show\": true,\n",
       "                    \"scale\": false,\n",
       "                    \"nameLocation\": \"end\",\n",
       "                    \"nameGap\": 15,\n",
       "                    \"gridIndex\": 0,\n",
       "                    \"inverse\": false,\n",
       "                    \"offset\": 0,\n",
       "                    \"splitNumber\": 5,\n",
       "                    \"minInterval\": 0,\n",
       "                    \"splitLine\": {\n",
       "                        \"show\": false,\n",
       "                        \"lineStyle\": {\n",
       "                            \"show\": true,\n",
       "                            \"width\": 1,\n",
       "                            \"opacity\": 1,\n",
       "                            \"curveness\": 0,\n",
       "                            \"type\": \"solid\"\n",
       "                        }\n",
       "                    },\n",
       "                    \"data\": [\n",
       "                        \"\\u7f8e\\u52a0\\u51c0\",\n",
       "                        \"\\u5170\\u829d\",\n",
       "                        \"\\u4f70\\u8349\\u96c6\",\n",
       "                        \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                        \"\\u81ea\\u7136\\u5802\",\n",
       "                        \"\\u6b27\\u83b1\\u96c5\",\n",
       "                        \"\\u59ae\\u7ef4\\u96c5\",\n",
       "                        \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                        \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                        \"\\u76f8\\u5b9c\\u672c\\u8349\"\n",
       "                    ]\n",
       "                }\n",
       "            ],\n",
       "            \"title\": [\n",
       "                {\n",
       "                    \"text\": \"\\u7d2f\\u8ba1\\u9500\\u552e\\u91cf\\u6392\\u884c TOP10\",\n",
       "                    \"padding\": 5,\n",
       "                    \"itemGap\": 10\n",
       "                }\n",
       "            ],\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"color\": [\n",
       "                \"#c23531\",\n",
       "                \"#2f4554\",\n",
       "                \"#61a0a8\",\n",
       "                \"#d48265\",\n",
       "                \"#749f83\",\n",
       "                \"#ca8622\",\n",
       "                \"#bda29a\",\n",
       "                \"#6e7074\",\n",
       "                \"#546570\",\n",
       "                \"#c4ccd3\",\n",
       "                \"#f05b72\",\n",
       "                \"#ef5b9c\",\n",
       "                \"#f47920\",\n",
       "                \"#905a3d\",\n",
       "                \"#fab27b\",\n",
       "                \"#2a5caa\",\n",
       "                \"#444693\",\n",
       "                \"#726930\",\n",
       "                \"#b2d235\",\n",
       "                \"#6d8346\",\n",
       "                \"#ac6767\",\n",
       "                \"#1d953f\",\n",
       "                \"#6950a1\",\n",
       "                \"#918597\"\n",
       "            ]\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_31b1855d502244f7a109787c9ae52104.setOption(option_31b1855d502244f7a109787c9ae52104);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1c77e7c4a58>"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Map, Timeline, Bar, Line, Pie\n",
    "from pyecharts.components import Table\n",
    "from pyecharts.options import ComponentTitleOpts\n",
    "\n",
    "tl = Timeline()\n",
    "tl.add_schema(\n",
    "#         is_auto_play=True,\n",
    "        is_loop_play=False,\n",
    "        play_interval=500,\n",
    "    )\n",
    "for dt in dts:\n",
    "    item = data2[data2['update_time'] <= dt].groupby('店名').agg({'sale_count': 'sum', 'sale_amount': 'sum'}).sort_values(by='sale_count', ascending=False)[:10].sort_values(by='sale_count').to_dict()\n",
    "    bar = (\n",
    "        Bar()\n",
    "        .add_xaxis([*item['sale_count'].keys()])\n",
    "        .add_yaxis(\"销售量\", [round(val/10000,2) for val in item['sale_count'].values()], label_opts=opts.LabelOpts(position=\"right\", formatter='{@[1]/} 万'))\n",
    "        .add_yaxis(\"销售额\", [round(val/10000/10000,2) for val in item['sale_amount'].values()], label_opts=opts.LabelOpts(position=\"right\", formatter='{@[1]/} 亿元'))\n",
    "        .reversal_axis()\n",
    "        .set_global_opts(\n",
    "            title_opts=opts.TitleOpts(\"累计销售量排行 TOP10\")\n",
    "        )\n",
    "    )\n",
    "    tl.add(bar, dt)\n",
    "tl.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "positive-basement",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"b75c057c9a9c4056bb7752a47b9dc0fd\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_b75c057c9a9c4056bb7752a47b9dc0fd = echarts.init(\n",
       "                    document.getElementById('b75c057c9a9c4056bb7752a47b9dc0fd'), 'white', {renderer: 'canvas'});\n",
       "                var option_b75c057c9a9c4056bb7752a47b9dc0fd = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"\\u9500\\u91cf\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u76f8\\u5b9c\\u672c\\u8349\",\n",
       "                    \"value\": 6546.29\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                    \"value\": 3935.81\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                    \"value\": 3907.05\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u59ae\\u7ef4\\u96c5\",\n",
       "                    \"value\": 3825.45\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6b27\\u83b1\\u96c5\",\n",
       "                    \"value\": 3377.32\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u81ea\\u7136\\u5802\",\n",
       "                    \"value\": 1783.75\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                    \"value\": 1539.12\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4f70\\u8349\\u96c6\",\n",
       "                    \"value\": 1499.45\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5170\\u829d\",\n",
       "                    \"value\": 913.02\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7f8e\\u52a0\\u51c0\",\n",
       "                    \"value\": 882.59\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"0%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{b}: {c} \\u4e07({d}%)\"\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u76f8\\u5b9c\\u672c\\u8349\",\n",
       "                \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                \"\\u59ae\\u7ef4\\u96c5\",\n",
       "                \"\\u6b27\\u83b1\\u96c5\",\n",
       "                \"\\u81ea\\u7136\\u5802\",\n",
       "                \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                \"\\u4f70\\u8349\\u96c6\",\n",
       "                \"\\u5170\\u829d\",\n",
       "                \"\\u7f8e\\u52a0\\u51c0\"\n",
       "            ],\n",
       "            \"selected\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    }\n",
       "};\n",
       "                chart_b75c057c9a9c4056bb7752a47b9dc0fd.setOption(option_b75c057c9a9c4056bb7752a47b9dc0fd);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1c77e7ca710>"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "item = data2.groupby('店名').agg({'sale_count': 'sum'}).sort_values(by='sale_count', ascending=False)[:10].to_dict()['sale_count']\n",
    "item = {k: round(v/10000, 2) for k, v in item.items()}\n",
    "c = (\n",
    "    Pie()\n",
    "    .add(\"销量\", [*item.items()])\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}: {c} 万({d}%)\"))\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "confident-mattress",
   "metadata": {},
   "source": [
    "#### 2.4 谁家的化妆品最贵"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "acute-wesley",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"e605429538f64799b5c1d6cc02b8e432\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_e605429538f64799b5c1d6cc02b8e432 = echarts.init(\n",
       "                    document.getElementById('e605429538f64799b5c1d6cc02b8e432'), 'white', {renderer: 'canvas'});\n",
       "                var option_e605429538f64799b5c1d6cc02b8e432 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u9500\\u552e\\u91cf\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                121.25,\n",
       "                122.96,\n",
       "                142.12,\n",
       "                148.76,\n",
       "                167.28,\n",
       "                180.13,\n",
       "                212.62,\n",
       "                276.22,\n",
       "                281.09,\n",
       "                289.82,\n",
       "                311.79,\n",
       "                329.66,\n",
       "                346.09,\n",
       "                356.62,\n",
       "                577.44,\n",
       "                756.4,\n",
       "                872.47,\n",
       "                901.08,\n",
       "                1011.73,\n",
       "                1361.04\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u9500\\u552e\\u91cf\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u9500\\u552e\\u91cf\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u60a6\\u8bd7\\u98ce\\u541f\",\n",
       "                \"\\u76f8\\u5b9c\\u672c\\u8349\",\n",
       "                \"\\u871c\\u4e1d\\u4f5b\\u9640\",\n",
       "                \"\\u7f8e\\u5b9d\\u83b2\",\n",
       "                \"\\u6b27\\u83b1\\u96c5\",\n",
       "                \"\\u81ea\\u7136\\u5802\",\n",
       "                \"\\u96c5\\u6f3e\",\n",
       "                \"\\u6b27\\u73c0\\u83b1\",\n",
       "                \"\\u8587\\u59ff\",\n",
       "                \"\\u4f70\\u8349\\u96c6\",\n",
       "                \"\\u690d\\u6751\\u79c0\",\n",
       "                \"\\u7389\\u5170\\u6cb9\",\n",
       "                \"\\u5029\\u78a7\",\n",
       "                \"\\u5170\\u829d\",\n",
       "                \"\\u8d44\\u751f\\u5802\",\n",
       "                \"\\u5170\\u853b\",\n",
       "                \"\\u96c5\\u8bd7\\u5170\\u9edb\",\n",
       "                \"\\u96ea\\u82b1\\u79c0\",\n",
       "                \"SKII\",\n",
       "                \"\\u5a07\\u5170\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5e73\\u5747\\u4ef7\\u683c\\u6392\\u884c TOP20\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_e605429538f64799b5c1d6cc02b8e432.setOption(option_e605429538f64799b5c1d6cc02b8e432);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1c77df051d0>"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "item = data2.groupby('店名').agg({'price': 'mean'}).sort_values(by='price', ascending=False)[:20].sort_values(by='price').to_dict()\n",
    "c = (\n",
    "    Bar()\n",
    "    .add_xaxis([*item['price'].keys()])\n",
    "    .add_yaxis(\"销售量\", [round(v, 2) for v in item['price'].values()], label_opts=opts.LabelOpts(position=\"right\"))\n",
    "    .reversal_axis()\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(\"平均价格排行 TOP20\")\n",
    "    )\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "virgin-purple",
   "metadata": {},
   "source": [
    "## part3\n",
    "\n",
    "日化.xlsx 这个数据集是美妆类商品的订单数据，从数量来看，应该是批发类的订单。包含两个 sheet 页（订单表和商品表），可以挖掘的纬度有日期、地区、商品，指标则有销售量、销售额、增长率等。\n",
    "### 1、数据理解与处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "otherwise-drama",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd \n",
    "fact_order = pd.read_excel('日化.xlsx', sheet_name='销售订单表')\n",
    "dim_product = pd.read_excel('日化.xlsx', sheet_name='商品信息表')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "underlying-registrar",
   "metadata": {},
   "source": [
    "#### 1.1 商品表数据清洗"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "sexual-austin",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>商品编号</th>\n",
       "      <th>商品名称</th>\n",
       "      <th>商品小类</th>\n",
       "      <th>商品大类</th>\n",
       "      <th>销售单价</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>X001</td>\n",
       "      <td>商品1</td>\n",
       "      <td>面膜</td>\n",
       "      <td>护肤品</td>\n",
       "      <td>121</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>X002</td>\n",
       "      <td>商品2</td>\n",
       "      <td>面膜</td>\n",
       "      <td>护肤品</td>\n",
       "      <td>141</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>X003</td>\n",
       "      <td>商品3</td>\n",
       "      <td>面膜</td>\n",
       "      <td>护肤品</td>\n",
       "      <td>168</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>X004</td>\n",
       "      <td>商品4</td>\n",
       "      <td>面膜</td>\n",
       "      <td>护肤品</td>\n",
       "      <td>211</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>X005</td>\n",
       "      <td>商品5</td>\n",
       "      <td>面膜</td>\n",
       "      <td>护肤品</td>\n",
       "      <td>185</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   商品编号 商品名称 商品小类 商品大类  销售单价\n",
       "0  X001  商品1   面膜  护肤品   121\n",
       "1  X002  商品2   面膜  护肤品   141\n",
       "2  X003  商品3   面膜  护肤品   168\n",
       "3  X004  商品4   面膜  护肤品   211\n",
       "4  X005  商品5   面膜  护肤品   185"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dim_product.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "assumed-ideal",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>销售单价</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>122.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>156.155738</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>58.454619</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>56.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>102.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>158.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>210.750000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>253.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             销售单价\n",
       "count  122.000000\n",
       "mean   156.155738\n",
       "std     58.454619\n",
       "min     56.000000\n",
       "25%    102.250000\n",
       "50%    158.000000\n",
       "75%    210.750000\n",
       "max    253.000000"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dim_product.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "organizational-tract",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "商品编号    0\n",
       "商品名称    0\n",
       "商品小类    0\n",
       "商品大类    0\n",
       "销售单价    0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dim_product[dim_product.duplicated()].count()  # 没有完全重复的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "diagnostic-western",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "商品编号    0\n",
       "商品名称    0\n",
       "商品小类    0\n",
       "商品大类    0\n",
       "销售单价    0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dim_product[dim_product['商品编号'].duplicated()].count()  # ID 唯一没有重复"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "atomic-challenge",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "商品编号    0\n",
       "商品名称    0\n",
       "商品小类    0\n",
       "商品大类    0\n",
       "销售单价    0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dim_product.isnull().sum()   # 没有空值 "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "olive-massage",
   "metadata": {},
   "source": [
    "#### 1.2 订单表数据清洗"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "indie-profit",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单编码</th>\n",
       "      <th>订单日期</th>\n",
       "      <th>客户编码</th>\n",
       "      <th>所在区域</th>\n",
       "      <th>所在省份</th>\n",
       "      <th>所在地市</th>\n",
       "      <th>商品编号</th>\n",
       "      <th>订购数量</th>\n",
       "      <th>订购单价</th>\n",
       "      <th>金额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>D31313</td>\n",
       "      <td>2019-05-16 00:00:00</td>\n",
       "      <td>S22796</td>\n",
       "      <td>东区</td>\n",
       "      <td>浙江省</td>\n",
       "      <td>台州市</td>\n",
       "      <td>X091</td>\n",
       "      <td>892</td>\n",
       "      <td>214</td>\n",
       "      <td>190888.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>D21329</td>\n",
       "      <td>2019-05-14 00:00:00</td>\n",
       "      <td>S11460</td>\n",
       "      <td>东区</td>\n",
       "      <td>安徽省</td>\n",
       "      <td>宿州市</td>\n",
       "      <td>X005</td>\n",
       "      <td>276</td>\n",
       "      <td>185</td>\n",
       "      <td>51060.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>D22372</td>\n",
       "      <td>2019-08-26 00:00:00</td>\n",
       "      <td>S11101</td>\n",
       "      <td>北区</td>\n",
       "      <td>山西省</td>\n",
       "      <td>忻州市</td>\n",
       "      <td>X078</td>\n",
       "      <td>1450</td>\n",
       "      <td>116</td>\n",
       "      <td>168200.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>D31078</td>\n",
       "      <td>2019-04-08 00:00:00</td>\n",
       "      <td>S10902</td>\n",
       "      <td>北区</td>\n",
       "      <td>吉林省</td>\n",
       "      <td>延边朝鲜族自治州</td>\n",
       "      <td>X025</td>\n",
       "      <td>1834</td>\n",
       "      <td>102</td>\n",
       "      <td>187068.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>D32470</td>\n",
       "      <td>2019-04-11 00:00:00</td>\n",
       "      <td>S18696</td>\n",
       "      <td>北区</td>\n",
       "      <td>北京市</td>\n",
       "      <td>北京市</td>\n",
       "      <td>X010</td>\n",
       "      <td>887</td>\n",
       "      <td>58</td>\n",
       "      <td>51446.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     订单编码                 订单日期    客户编码 所在区域 所在省份      所在地市  商品编号  订购数量 订购单价  \\\n",
       "0  D31313  2019-05-16 00:00:00  S22796   东区  浙江省       台州市  X091   892  214   \n",
       "1  D21329  2019-05-14 00:00:00  S11460   东区  安徽省       宿州市  X005   276  185   \n",
       "2  D22372  2019-08-26 00:00:00  S11101   北区  山西省       忻州市  X078  1450  116   \n",
       "3  D31078  2019-04-08 00:00:00  S10902   北区  吉林省  延边朝鲜族自治州  X025  1834  102   \n",
       "4  D32470  2019-04-11 00:00:00  S18696   北区  北京市       北京市  X010   887   58   \n",
       "\n",
       "         金额  \n",
       "0  190888.0  \n",
       "1   51060.0  \n",
       "2  168200.0  \n",
       "3  187068.0  \n",
       "4   51446.0  "
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fact_order.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "bibliographic-island",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 31452 entries, 0 to 31451\n",
      "Data columns (total 10 columns):\n",
      " #   Column  Non-Null Count  Dtype  \n",
      "---  ------  --------------  -----  \n",
      " 0   订单编码    31452 non-null  object \n",
      " 1   订单日期    31452 non-null  object \n",
      " 2   客户编码    31452 non-null  object \n",
      " 3   所在区域    31450 non-null  object \n",
      " 4   所在省份    31450 non-null  object \n",
      " 5   所在地市    31452 non-null  object \n",
      " 6   商品编号    31451 non-null  object \n",
      " 7   订购数量    31450 non-null  object \n",
      " 8   订购单价    31448 non-null  object \n",
      " 9   金额      31448 non-null  float64\n",
      "dtypes: float64(1), object(9)\n",
      "memory usage: 2.4+ MB\n"
     ]
    }
   ],
   "source": [
    "fact_order.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "intensive-houston",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "订单编码    6\n",
       "订单日期    6\n",
       "客户编码    6\n",
       "所在区域    6\n",
       "所在省份    6\n",
       "所在地市    6\n",
       "商品编号    6\n",
       "订购数量    6\n",
       "订购单价    6\n",
       "金额      6\n",
       "dtype: int64"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fact_order[fact_order.duplicated()].count()  # 没有完全重复的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "amber-wedding",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "订单编码    0\n",
       "订单日期    0\n",
       "客户编码    0\n",
       "所在区域    2\n",
       "所在省份    2\n",
       "所在地市    0\n",
       "商品编号    1\n",
       "订购数量    2\n",
       "订购单价    4\n",
       "金额      4\n",
       "dtype: int64"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fact_order.drop_duplicates(inplace=True)   # 删除重复数据\n",
    "fact_order.reset_index(drop=True, inplace=True)  # 重建索引\n",
    "fact_order.isnull().sum()  # 查看空值，有几条数据缺失"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "suspected-rhythm",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "订单编码    0\n",
       "订单日期    0\n",
       "客户编码    0\n",
       "所在区域    0\n",
       "所在省份    0\n",
       "所在地市    0\n",
       "商品编号    0\n",
       "订购数量    0\n",
       "订购单价    0\n",
       "金额      0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fact_order.fillna(method='bfill', inplace=True) # 空值填充\n",
    "fact_order.fillna(method='ffill', inplace=True) # 空值填充\n",
    "fact_order.isnull().sum()  # 查看空值，有几条数据缺失"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "golden-photograph",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单编码</th>\n",
       "      <th>订单日期</th>\n",
       "      <th>客户编码</th>\n",
       "      <th>所在区域</th>\n",
       "      <th>所在省份</th>\n",
       "      <th>所在地市</th>\n",
       "      <th>商品编号</th>\n",
       "      <th>订购数量</th>\n",
       "      <th>订购单价</th>\n",
       "      <th>金额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20797</th>\n",
       "      <td>D26533</td>\n",
       "      <td>2050-06-09</td>\n",
       "      <td>S21396</td>\n",
       "      <td>北区</td>\n",
       "      <td>河北省</td>\n",
       "      <td>石家庄市</td>\n",
       "      <td>X022</td>\n",
       "      <td>759</td>\n",
       "      <td>158</td>\n",
       "      <td>119922.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         订单编码       订单日期    客户编码 所在区域 所在省份  所在地市  商品编号 订购数量 订购单价        金额\n",
       "20797  D26533 2050-06-09  S21396   北区  河北省  石家庄市  X022  759  158  119922.0"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fact_order['订单日期'] = fact_order['订单日期'].apply(lambda x: pd.to_datetime(x, format='%Y#%m#%d') if isinstance(x, str) else x)\n",
    "fact_order[fact_order['订单日期'] > '2021-01-01'] # 有一条脏数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "lined-throw",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(Timestamp('2019-09-30 00:00:00'), Timestamp('2019-01-01 00:00:00'))"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fact_order = fact_order[fact_order['订单日期'] < '2021-01-01'] # 过滤掉脏数据\n",
    "fact_order['订单日期'].max(), fact_order['订单日期'].min()  # 数据区间在 2019-01-01 到 2019-09-30 之间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "coated-boston",
   "metadata": {},
   "outputs": [],
   "source": [
    "fact_order['订购数量'] = fact_order['订购数量'].apply(lambda x: x.strip('个') if isinstance(x, str) else x).astype('int')\n",
    "fact_order['订购单价'] = fact_order['订购单价'].apply(lambda x: x.strip('元') if isinstance(x, str) else x).astype('float')\n",
    "fact_order['金额'] = fact_order['金额'].astype('float')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "regular-colorado",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 31445 entries, 0 to 31445\n",
      "Data columns (total 10 columns):\n",
      " #   Column  Non-Null Count  Dtype         \n",
      "---  ------  --------------  -----         \n",
      " 0   订单编码    31445 non-null  object        \n",
      " 1   订单日期    31445 non-null  datetime64[ns]\n",
      " 2   客户编码    31445 non-null  object        \n",
      " 3   所在区域    31445 non-null  object        \n",
      " 4   所在省份    31445 non-null  object        \n",
      " 5   所在地市    31445 non-null  object        \n",
      " 6   商品编号    31445 non-null  object        \n",
      " 7   订购数量    31445 non-null  int32         \n",
      " 8   订购单价    31445 non-null  float64       \n",
      " 9   金额      31445 non-null  float64       \n",
      "dtypes: datetime64[ns](1), float64(2), int32(1), object(6)\n",
      "memory usage: 2.5+ MB\n"
     ]
    }
   ],
   "source": [
    "fact_order.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "potential-recording",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['浙江', '安徽', '山西', '吉林', '北京', '云南', '广东', '广西', '内蒙古', '新疆', '湖北',\n",
       "       '江苏', '甘肃', '四川', '河南', '福建', '陕西', '辽宁', '山东', '江西', '重庆', '河北',\n",
       "       '湖南', '上海', '贵州', '天津', '海南', '宁夏', '黑龙江'], dtype=object)"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fact_order['所在省份'] = fact_order['所在省份'].str.replace('自治区|维吾尔|回族|壮族|省|市', '')  # 对省份做个清洗，便于可视化\n",
    "fact_order['所在省份'].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "usual-suspect",
   "metadata": {},
   "outputs": [],
   "source": [
    "fact_order['客户编码'] = fact_order['客户编码'].str.replace('编号', '')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "speaking-angle",
   "metadata": {},
   "source": [
    "### 2、数据分析与可视化\n",
    "#### 2.1 每月订购情况"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "french-entry",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"db3f8a68e79149f4a4bfa6897e08f11b\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_db3f8a68e79149f4a4bfa6897e08f11b = echarts.init(\n",
       "                    document.getElementById('db3f8a68e79149f4a4bfa6897e08f11b'), 'white', {renderer: 'canvas'});\n",
       "                var option_db3f8a68e79149f4a4bfa6897e08f11b = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8ba2\\u8d2d\\u6570\\u91cf\\uff08\\u4e07\\u4ef6\\uff09\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                194.74,\n",
       "                214.82,\n",
       "                256.89,\n",
       "                318.53,\n",
       "                359.09,\n",
       "                355.38,\n",
       "                388.68,\n",
       "                383.36,\n",
       "                311.59\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u91d1\\u989d\\uff08\\u4ebf\\u5143\\uff09\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                3.14,\n",
       "                3.44,\n",
       "                4.13,\n",
       "                5.05,\n",
       "                5.75,\n",
       "                5.74,\n",
       "                6.22,\n",
       "                6.08,\n",
       "                4.99\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8ba2\\u8d2d\\u6570\\u91cf\\uff08\\u4e07\\u4ef6\\uff09\",\n",
       "                \"\\u91d1\\u989d\\uff08\\u4ebf\\u5143\\uff09\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u8ba2\\u8d2d\\u6570\\u91cf\\uff08\\u4e07\\u4ef6\\uff09\": false,\n",
       "                \"\\u91d1\\u989d\\uff08\\u4ebf\\u5143\\uff09\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"1 \\u6708\",\n",
       "                \"2 \\u6708\",\n",
       "                \"3 \\u6708\",\n",
       "                \"4 \\u6708\",\n",
       "                \"5 \\u6708\",\n",
       "                \"6 \\u6708\",\n",
       "                \"7 \\u6708\",\n",
       "                \"8 \\u6708\",\n",
       "                \"9 \\u6708\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6bcf\\u6708\\u8ba2\\u8d2d\\u60c5\\u51b5\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_db3f8a68e79149f4a4bfa6897e08f11b.setOption(option_db3f8a68e79149f4a4bfa6897e08f11b);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1c77e81de80>"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Map, Bar, Line\n",
    "from pyecharts.components import Table\n",
    "from pyecharts.options import ComponentTitleOpts\n",
    "from pyecharts.faker import Faker\n",
    "\n",
    "fact_order['订单月份'] = fact_order['订单日期'].apply(lambda x: x.month) \n",
    "item = fact_order.groupby('订单月份').agg({'订购数量': 'sum', '金额': 'sum'}).to_dict()\n",
    "x = [f'{key} 月' for key in item['订购数量'].keys()]\n",
    "y1 = [round(val/10000, 2) for val in item['订购数量'].values()]\n",
    "y2 = [round(val/10000/10000, 2) for val in item['金额'].values()]\n",
    "c = (\n",
    "    Bar()\n",
    "    .add_xaxis(x)\n",
    "    .add_yaxis(\"订购数量（万件）\", y1, is_selected=False)\n",
    "    .add_yaxis(\"金额（亿元）\", y2)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"每月订购情况\"))\n",
    "    .set_series_opts(\n",
    "        label_opts=opts.LabelOpts(is_show=True),\n",
    "    )\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "sitting-yacht",
   "metadata": {},
   "source": [
    "#### 2.2 哪里的人最爱美"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "incomplete-maria",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"9b427ffa883e47feae8db7bb05999d38\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_9b427ffa883e47feae8db7bb05999d38 = echarts.init(\n",
       "                    document.getElementById('9b427ffa883e47feae8db7bb05999d38'), 'white', {renderer: 'canvas'});\n",
       "                var option_9b427ffa883e47feae8db7bb05999d38 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8ba2\\u8d2d\\u91cf\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                27.56,\n",
       "                27.58,\n",
       "                31.43,\n",
       "                34.18,\n",
       "                34.31,\n",
       "                36.14,\n",
       "                38.12,\n",
       "                39.55,\n",
       "                39.87,\n",
       "                41.35,\n",
       "                42.51,\n",
       "                45.22,\n",
       "                52.41,\n",
       "                56.27,\n",
       "                56.38,\n",
       "                73.81,\n",
       "                77.83,\n",
       "                80.54,\n",
       "                101.05,\n",
       "                112.53\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{@[1]/} \\u4e07\"\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8ba2\\u8d2d\\u91cf\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u8ba2\\u8d2d\\u91cf\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u5357\\u660c\\u5e02\",\n",
       "                \"\\u798f\\u5dde\\u5e02\",\n",
       "                \"\\u626c\\u5dde\\u5e02\",\n",
       "                \"\\u4e1c\\u839e\\u5e02\",\n",
       "                \"\\u6e29\\u5dde\\u5e02\",\n",
       "                \"\\u5e38\\u5dde\\u5e02\",\n",
       "                \"\\u65e0\\u9521\\u5e02\",\n",
       "                \"\\u5357\\u4eac\\u5e02\",\n",
       "                \"\\u957f\\u6c99\\u5e02\",\n",
       "                \"\\u6cf0\\u5dde\\u5e02\",\n",
       "                \"\\u5b81\\u6ce2\\u5e02\",\n",
       "                \"\\u5357\\u901a\\u5e02\",\n",
       "                \"\\u5e7f\\u5dde\\u5e02\",\n",
       "                \"\\u5317\\u4eac\\u5e02\",\n",
       "                \"\\u676d\\u5dde\\u5e02\",\n",
       "                \"\\u6cc9\\u5dde\\u5e02\",\n",
       "                \"\\u6df1\\u5733\\u5e02\",\n",
       "                \"\\u91cd\\u5e86\\u5e02\",\n",
       "                \"\\u82cf\\u5dde\\u5e02\",\n",
       "                \"\\u4e0a\\u6d77\\u5e02\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8ba2\\u8d2d\\u6570\\u91cf\\u6392\\u884c TOP20\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_9b427ffa883e47feae8db7bb05999d38.setOption(option_9b427ffa883e47feae8db7bb05999d38);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1c7382e7da0>"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "item = fact_order.groupby('所在地市').agg({'订购数量': 'sum'}).sort_values(by='订购数量', ascending=False)[:20].sort_values(by='订购数量').to_dict()['订购数量']\n",
    "\n",
    "c = (\n",
    "    Bar()\n",
    "    .add_xaxis([*item.keys()])\n",
    "    .add_yaxis(\"订购量\", [round(v/10000, 2) for v in item.values()], label_opts=opts.LabelOpts(position=\"right\", formatter='{@[1]/} 万'))\n",
    "    .reversal_axis()\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(\"订购数量排行 TOP20\")\n",
    "    )\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "broken-estimate",
   "metadata": {},
   "source": [
    "#### 2.3 什么类型的美妆需求量最大"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "seasonal-particle",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单编码</th>\n",
       "      <th>订单日期</th>\n",
       "      <th>客户编码</th>\n",
       "      <th>所在区域</th>\n",
       "      <th>所在省份</th>\n",
       "      <th>所在地市</th>\n",
       "      <th>商品编号</th>\n",
       "      <th>订购数量</th>\n",
       "      <th>订购单价</th>\n",
       "      <th>金额</th>\n",
       "      <th>订单月份</th>\n",
       "      <th>商品名称</th>\n",
       "      <th>商品小类</th>\n",
       "      <th>商品大类</th>\n",
       "      <th>销售单价</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>D31313</td>\n",
       "      <td>2019-05-16</td>\n",
       "      <td>S22796</td>\n",
       "      <td>东区</td>\n",
       "      <td>浙江</td>\n",
       "      <td>台州市</td>\n",
       "      <td>X091</td>\n",
       "      <td>892</td>\n",
       "      <td>214.0</td>\n",
       "      <td>190888.0</td>\n",
       "      <td>5</td>\n",
       "      <td>商品91</td>\n",
       "      <td>粉底</td>\n",
       "      <td>彩妆</td>\n",
       "      <td>214</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>D26674</td>\n",
       "      <td>2019-05-01</td>\n",
       "      <td>S15128</td>\n",
       "      <td>东区</td>\n",
       "      <td>江苏</td>\n",
       "      <td>南通市</td>\n",
       "      <td>X091</td>\n",
       "      <td>1133</td>\n",
       "      <td>214.0</td>\n",
       "      <td>242462.0</td>\n",
       "      <td>5</td>\n",
       "      <td>商品91</td>\n",
       "      <td>粉底</td>\n",
       "      <td>彩妆</td>\n",
       "      <td>214</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>D23381</td>\n",
       "      <td>2019-09-22</td>\n",
       "      <td>S17133</td>\n",
       "      <td>东区</td>\n",
       "      <td>江苏</td>\n",
       "      <td>宿迁市</td>\n",
       "      <td>X091</td>\n",
       "      <td>1136</td>\n",
       "      <td>214.0</td>\n",
       "      <td>243104.0</td>\n",
       "      <td>9</td>\n",
       "      <td>商品91</td>\n",
       "      <td>粉底</td>\n",
       "      <td>彩妆</td>\n",
       "      <td>214</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>D29060</td>\n",
       "      <td>2019-09-10</td>\n",
       "      <td>S14106</td>\n",
       "      <td>东区</td>\n",
       "      <td>江苏</td>\n",
       "      <td>常州市</td>\n",
       "      <td>X091</td>\n",
       "      <td>544</td>\n",
       "      <td>214.0</td>\n",
       "      <td>116416.0</td>\n",
       "      <td>9</td>\n",
       "      <td>商品91</td>\n",
       "      <td>粉底</td>\n",
       "      <td>彩妆</td>\n",
       "      <td>214</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>D21234</td>\n",
       "      <td>2019-07-03</td>\n",
       "      <td>S17197</td>\n",
       "      <td>东区</td>\n",
       "      <td>湖北</td>\n",
       "      <td>十堰市</td>\n",
       "      <td>X091</td>\n",
       "      <td>342</td>\n",
       "      <td>214.0</td>\n",
       "      <td>73188.0</td>\n",
       "      <td>7</td>\n",
       "      <td>商品91</td>\n",
       "      <td>粉底</td>\n",
       "      <td>彩妆</td>\n",
       "      <td>214</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31439</th>\n",
       "      <td>D30482</td>\n",
       "      <td>2019-06-05</td>\n",
       "      <td>S11033</td>\n",
       "      <td>东区</td>\n",
       "      <td>浙江</td>\n",
       "      <td>金华市</td>\n",
       "      <td>X118</td>\n",
       "      <td>551</td>\n",
       "      <td>238.0</td>\n",
       "      <td>131138.0</td>\n",
       "      <td>6</td>\n",
       "      <td>商品118</td>\n",
       "      <td>蜜粉</td>\n",
       "      <td>彩妆</td>\n",
       "      <td>238</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31440</th>\n",
       "      <td>D29542</td>\n",
       "      <td>2019-05-01</td>\n",
       "      <td>S12446</td>\n",
       "      <td>东区</td>\n",
       "      <td>江苏</td>\n",
       "      <td>南通市</td>\n",
       "      <td>X118</td>\n",
       "      <td>165</td>\n",
       "      <td>238.0</td>\n",
       "      <td>39270.0</td>\n",
       "      <td>5</td>\n",
       "      <td>商品118</td>\n",
       "      <td>蜜粉</td>\n",
       "      <td>彩妆</td>\n",
       "      <td>238</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31441</th>\n",
       "      <td>D24798</td>\n",
       "      <td>2019-06-26</td>\n",
       "      <td>S16170</td>\n",
       "      <td>南区</td>\n",
       "      <td>福建</td>\n",
       "      <td>泉州市</td>\n",
       "      <td>X118</td>\n",
       "      <td>62</td>\n",
       "      <td>238.0</td>\n",
       "      <td>14756.0</td>\n",
       "      <td>6</td>\n",
       "      <td>商品118</td>\n",
       "      <td>蜜粉</td>\n",
       "      <td>彩妆</td>\n",
       "      <td>238</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31442</th>\n",
       "      <td>D31831</td>\n",
       "      <td>2019-08-13</td>\n",
       "      <td>S22214</td>\n",
       "      <td>北区</td>\n",
       "      <td>黑龙江</td>\n",
       "      <td>佳木斯市</td>\n",
       "      <td>X118</td>\n",
       "      <td>795</td>\n",
       "      <td>238.0</td>\n",
       "      <td>189210.0</td>\n",
       "      <td>8</td>\n",
       "      <td>商品118</td>\n",
       "      <td>蜜粉</td>\n",
       "      <td>彩妆</td>\n",
       "      <td>238</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31443</th>\n",
       "      <td>D28890</td>\n",
       "      <td>2019-07-21</td>\n",
       "      <td>S15066</td>\n",
       "      <td>西区</td>\n",
       "      <td>四川</td>\n",
       "      <td>南充市</td>\n",
       "      <td>X118</td>\n",
       "      <td>148</td>\n",
       "      <td>238.0</td>\n",
       "      <td>35224.0</td>\n",
       "      <td>7</td>\n",
       "      <td>商品118</td>\n",
       "      <td>蜜粉</td>\n",
       "      <td>彩妆</td>\n",
       "      <td>238</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>31444 rows × 15 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         订单编码       订单日期    客户编码 所在区域 所在省份  所在地市  商品编号  订购数量   订购单价        金额  \\\n",
       "0      D31313 2019-05-16  S22796   东区   浙江   台州市  X091   892  214.0  190888.0   \n",
       "1      D26674 2019-05-01  S15128   东区   江苏   南通市  X091  1133  214.0  242462.0   \n",
       "2      D23381 2019-09-22  S17133   东区   江苏   宿迁市  X091  1136  214.0  243104.0   \n",
       "3      D29060 2019-09-10  S14106   东区   江苏   常州市  X091   544  214.0  116416.0   \n",
       "4      D21234 2019-07-03  S17197   东区   湖北   十堰市  X091   342  214.0   73188.0   \n",
       "...       ...        ...     ...  ...  ...   ...   ...   ...    ...       ...   \n",
       "31439  D30482 2019-06-05  S11033   东区   浙江   金华市  X118   551  238.0  131138.0   \n",
       "31440  D29542 2019-05-01  S12446   东区   江苏   南通市  X118   165  238.0   39270.0   \n",
       "31441  D24798 2019-06-26  S16170   南区   福建   泉州市  X118    62  238.0   14756.0   \n",
       "31442  D31831 2019-08-13  S22214   北区  黑龙江  佳木斯市  X118   795  238.0  189210.0   \n",
       "31443  D28890 2019-07-21  S15066   西区   四川   南充市  X118   148  238.0   35224.0   \n",
       "\n",
       "       订单月份   商品名称 商品小类 商品大类  销售单价  \n",
       "0         5   商品91   粉底   彩妆   214  \n",
       "1         5   商品91   粉底   彩妆   214  \n",
       "2         9   商品91   粉底   彩妆   214  \n",
       "3         9   商品91   粉底   彩妆   214  \n",
       "4         7   商品91   粉底   彩妆   214  \n",
       "...     ...    ...  ...  ...   ...  \n",
       "31439     6  商品118   蜜粉   彩妆   238  \n",
       "31440     5  商品118   蜜粉   彩妆   238  \n",
       "31441     6  商品118   蜜粉   彩妆   238  \n",
       "31442     8  商品118   蜜粉   彩妆   238  \n",
       "31443     7  商品118   蜜粉   彩妆   238  \n",
       "\n",
       "[31444 rows x 15 columns]"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "order = pd.merge(fact_order, dim_product, on='商品编号',how='inner')  # 表关联\n",
    "order"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "amended-intensity",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>订购数量</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>商品大类</th>\n",
       "      <th>商品小类</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">彩妆</th>\n",
       "      <th>口红</th>\n",
       "      <td>2013024</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>粉底</th>\n",
       "      <td>1188621</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>睫毛膏</th>\n",
       "      <td>587399</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>眼影</th>\n",
       "      <td>296599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>蜜粉</th>\n",
       "      <td>45534</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"7\" valign=\"top\">护肤品</th>\n",
       "      <th>面膜</th>\n",
       "      <td>5451914</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>面霜</th>\n",
       "      <td>4566905</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>爽肤水</th>\n",
       "      <td>3523687</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>眼霜</th>\n",
       "      <td>3350743</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>隔离霜</th>\n",
       "      <td>2488124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>防晒霜</th>\n",
       "      <td>2388610</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>洁面乳</th>\n",
       "      <td>1928020</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              订购数量\n",
       "商品大类 商品小类         \n",
       "彩妆   口红    2013024\n",
       "     粉底    1188621\n",
       "     睫毛膏    587399\n",
       "     眼影     296599\n",
       "     蜜粉      45534\n",
       "护肤品  面膜    5451914\n",
       "     面霜    4566905\n",
       "     爽肤水   3523687\n",
       "     眼霜    3350743\n",
       "     隔离霜   2488124\n",
       "     防晒霜   2388610\n",
       "     洁面乳   1928020"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "order.groupby(['商品大类','商品小类']).agg({'订购数量': 'sum'}).sort_values(by=['商品大类', '订购数量'], ascending=[True, False])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "changed-sentence",
   "metadata": {},
   "source": [
    "#### 2.4 哪些省份的美妆需求量最大"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "opponent-buying",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'china':'https://assets.pyecharts.org/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"57156cf4c96a4c04a87041f1481ec427\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_57156cf4c96a4c04a87041f1481ec427 = echarts.init(\n",
       "                    document.getElementById('57156cf4c96a4c04a87041f1481ec427'), 'white', {renderer: 'canvas'});\n",
       "                var option_57156cf4c96a4c04a87041f1481ec427 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"map\",\n",
       "            \"name\": \"\\u8ba2\\u8d2d\\u6570\\u91cf\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"mapType\": \"china\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u4e0a\\u6d77\",\n",
       "                    \"value\": 1125312\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e91\\u5357\",\n",
       "                    \"value\": 706882\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5185\\u8499\\u53e4\",\n",
       "                    \"value\": 120813\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5317\\u4eac\",\n",
       "                    \"value\": 561432\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5409\\u6797\",\n",
       "                    \"value\": 344333\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u56db\\u5ddd\",\n",
       "                    \"value\": 1351715\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5929\\u6d25\",\n",
       "                    \"value\": 155298\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b81\\u590f\",\n",
       "                    \"value\": 102254\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u5fbd\",\n",
       "                    \"value\": 1353512\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u4e1c\",\n",
       "                    \"value\": 1234058\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u897f\",\n",
       "                    \"value\": 516045\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u4e1c\",\n",
       "                    \"value\": 2952919\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u897f\",\n",
       "                    \"value\": 914145\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u7586\",\n",
       "                    \"value\": 202183\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u82cf\",\n",
       "                    \"value\": 4181096\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u897f\",\n",
       "                    \"value\": 934775\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5317\",\n",
       "                    \"value\": 963865\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5357\",\n",
       "                    \"value\": 552203\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d59\\u6c5f\",\n",
       "                    \"value\": 2360029\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d77\\u5357\",\n",
       "                    \"value\": 134901\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5317\",\n",
       "                    \"value\": 910203\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5357\",\n",
       "                    \"value\": 1314400\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7518\\u8083\",\n",
       "                    \"value\": 286306\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u798f\\u5efa\",\n",
       "                    \"value\": 1570181\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d35\\u5dde\",\n",
       "                    \"value\": 483007\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8fbd\\u5b81\",\n",
       "                    \"value\": 564647\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u91cd\\u5e86\",\n",
       "                    \"value\": 805434\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9655\\u897f\",\n",
       "                    \"value\": 647066\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ed1\\u9f99\\u6c5f\",\n",
       "                    \"value\": 481754\n",
       "                }\n",
       "            ],\n",
       "            \"roam\": true,\n",
       "            \"aspectScale\": 0.75,\n",
       "            \"nameProperty\": \"name\",\n",
       "            \"selectedMode\": false,\n",
       "            \"zoom\": 1,\n",
       "            \"mapValueCalculation\": \"sum\",\n",
       "            \"showLegendSymbol\": false,\n",
       "            \"emphasis\": {},\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8ba2\\u8d2d\\u6570\\u91cf\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u8ba2\\u8d2d\\u6570\\u91cf\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u7701\\u4efd\\u5206\\u5e03\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"continuous\",\n",
       "        \"min\": 0,\n",
       "        \"max\": 1000000,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"#50a3ba\",\n",
       "                \"#eac763\",\n",
       "                \"#d94e5d\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 140,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "                chart_57156cf4c96a4c04a87041f1481ec427.setOption(option_57156cf4c96a4c04a87041f1481ec427);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1c73852e6a0>"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "item = fact_order.groupby('所在省份').agg({'订购数量': 'sum'}).to_dict()['订购数量']\n",
    "c = (\n",
    "    Map()\n",
    "    .add(\"订购数量\", [*item.items()], \"china\", is_map_symbol_show=False)\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(is_show=True))\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title='省份分布'),\n",
    "        visualmap_opts=opts.VisualMapOpts(max_=1000000),            \n",
    "    )\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "distinguished-mercy",
   "metadata": {},
   "source": [
    "#### 2.5 通过 RFM 模型挖掘客户价值\n",
    "\n",
    "RFM 模型是衡量客户价值和客户创利能力的重要工具和手段，其中由3个要素构成了数据分析最好的指标，分别是：\n",
    "* R-Recency（最近一次购买时间）\n",
    "* F-Frequency（消费频率）\n",
    "* M-Money（消费金额）\n",
    "\n",
    "设定一个计算权重，比如 R-Recency 20%  F-Frequency 30%  M-Money 50% ，最后通过这个权重进行打分，量化客户价值，后续还可以基于分数进一步打标签，用来指导二次营销的策略。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "alpine-warning",
   "metadata": {},
   "outputs": [],
   "source": [
    "data_rfm = fact_order.groupby('客户编码').agg({'订单日期': 'max', '订单编码': 'count', '金额': 'sum'})\n",
    "data_rfm.columns = ['最近一次购买时间', '消费频率', '消费金额']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "absent-automation",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>最近一次购买时间</th>\n",
       "      <th>消费频率</th>\n",
       "      <th>消费金额</th>\n",
       "      <th>R</th>\n",
       "      <th>F</th>\n",
       "      <th>M</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>客户编码</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>S11609</th>\n",
       "      <td>2019-09-30</td>\n",
       "      <td>42</td>\n",
       "      <td>7326027.0</td>\n",
       "      <td>0.980148</td>\n",
       "      <td>0.796399</td>\n",
       "      <td>0.903970</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S19828</th>\n",
       "      <td>2019-09-30</td>\n",
       "      <td>21</td>\n",
       "      <td>2642275.0</td>\n",
       "      <td>0.980148</td>\n",
       "      <td>0.356879</td>\n",
       "      <td>0.306556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S17166</th>\n",
       "      <td>2019-09-30</td>\n",
       "      <td>17</td>\n",
       "      <td>3627037.0</td>\n",
       "      <td>0.980148</td>\n",
       "      <td>0.261311</td>\n",
       "      <td>0.478301</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S22925</th>\n",
       "      <td>2019-09-30</td>\n",
       "      <td>31</td>\n",
       "      <td>3449117.0</td>\n",
       "      <td>0.980148</td>\n",
       "      <td>0.591413</td>\n",
       "      <td>0.457987</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S10469</th>\n",
       "      <td>2019-09-30</td>\n",
       "      <td>30</td>\n",
       "      <td>4198071.0</td>\n",
       "      <td>0.980148</td>\n",
       "      <td>0.570175</td>\n",
       "      <td>0.564174</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S16503</th>\n",
       "      <td>2019-04-07</td>\n",
       "      <td>14</td>\n",
       "      <td>1682893.0</td>\n",
       "      <td>0.004617</td>\n",
       "      <td>0.198061</td>\n",
       "      <td>0.146814</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S17547</th>\n",
       "      <td>2019-03-14</td>\n",
       "      <td>10</td>\n",
       "      <td>1784531.0</td>\n",
       "      <td>0.003232</td>\n",
       "      <td>0.087258</td>\n",
       "      <td>0.163435</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S20864</th>\n",
       "      <td>2019-03-14</td>\n",
       "      <td>8</td>\n",
       "      <td>1118752.0</td>\n",
       "      <td>0.003232</td>\n",
       "      <td>0.039243</td>\n",
       "      <td>0.047091</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S11908</th>\n",
       "      <td>2019-03-09</td>\n",
       "      <td>9</td>\n",
       "      <td>1552311.0</td>\n",
       "      <td>0.001847</td>\n",
       "      <td>0.060942</td>\n",
       "      <td>0.125577</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S11611</th>\n",
       "      <td>2019-03-03</td>\n",
       "      <td>10</td>\n",
       "      <td>1487966.0</td>\n",
       "      <td>0.000923</td>\n",
       "      <td>0.087258</td>\n",
       "      <td>0.113573</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1083 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         最近一次购买时间  消费频率       消费金额         R         F         M\n",
       "客户编码                                                            \n",
       "S11609 2019-09-30    42  7326027.0  0.980148  0.796399  0.903970\n",
       "S19828 2019-09-30    21  2642275.0  0.980148  0.356879  0.306556\n",
       "S17166 2019-09-30    17  3627037.0  0.980148  0.261311  0.478301\n",
       "S22925 2019-09-30    31  3449117.0  0.980148  0.591413  0.457987\n",
       "S10469 2019-09-30    30  4198071.0  0.980148  0.570175  0.564174\n",
       "...           ...   ...        ...       ...       ...       ...\n",
       "S16503 2019-04-07    14  1682893.0  0.004617  0.198061  0.146814\n",
       "S17547 2019-03-14    10  1784531.0  0.003232  0.087258  0.163435\n",
       "S20864 2019-03-14     8  1118752.0  0.003232  0.039243  0.047091\n",
       "S11908 2019-03-09     9  1552311.0  0.001847  0.060942  0.125577\n",
       "S11611 2019-03-03    10  1487966.0  0.000923  0.087258  0.113573\n",
       "\n",
       "[1083 rows x 6 columns]"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_rfm['R'] = data_rfm['最近一次购买时间'].rank(pct=True)   # 转化为排名 百分比，便于后续切片\n",
    "data_rfm['F'] = data_rfm['消费频率'].rank(pct=True)\n",
    "data_rfm['M'] = data_rfm['消费金额'].rank(pct=True)\n",
    "data_rfm.sort_values(by='R', ascending=False)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "transsexual-frost",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>最近一次购买时间</th>\n",
       "      <th>消费频率</th>\n",
       "      <th>消费金额</th>\n",
       "      <th>R</th>\n",
       "      <th>F</th>\n",
       "      <th>M</th>\n",
       "      <th>score</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>客户编码</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>S17476</th>\n",
       "      <td>2019-09-30</td>\n",
       "      <td>69</td>\n",
       "      <td>10325832.0</td>\n",
       "      <td>0.980148</td>\n",
       "      <td>0.986611</td>\n",
       "      <td>0.987073</td>\n",
       "      <td>98.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S22326</th>\n",
       "      <td>2019-09-30</td>\n",
       "      <td>62</td>\n",
       "      <td>10074609.0</td>\n",
       "      <td>0.980148</td>\n",
       "      <td>0.973223</td>\n",
       "      <td>0.984303</td>\n",
       "      <td>98.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S11581</th>\n",
       "      <td>2019-09-28</td>\n",
       "      <td>79</td>\n",
       "      <td>10333668.0</td>\n",
       "      <td>0.918283</td>\n",
       "      <td>0.996768</td>\n",
       "      <td>0.987996</td>\n",
       "      <td>97.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S12848</th>\n",
       "      <td>2019-09-29</td>\n",
       "      <td>66</td>\n",
       "      <td>9673572.0</td>\n",
       "      <td>0.944598</td>\n",
       "      <td>0.980609</td>\n",
       "      <td>0.980609</td>\n",
       "      <td>97.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S19095</th>\n",
       "      <td>2019-09-26</td>\n",
       "      <td>81</td>\n",
       "      <td>11031632.0</td>\n",
       "      <td>0.864728</td>\n",
       "      <td>0.999077</td>\n",
       "      <td>0.996307</td>\n",
       "      <td>97.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S12690</th>\n",
       "      <td>2019-05-07</td>\n",
       "      <td>7</td>\n",
       "      <td>917233.0</td>\n",
       "      <td>0.012927</td>\n",
       "      <td>0.022622</td>\n",
       "      <td>0.024931</td>\n",
       "      <td>2.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S11176</th>\n",
       "      <td>2019-06-09</td>\n",
       "      <td>7</td>\n",
       "      <td>614134.0</td>\n",
       "      <td>0.036011</td>\n",
       "      <td>0.022622</td>\n",
       "      <td>0.009234</td>\n",
       "      <td>1.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S18379</th>\n",
       "      <td>2019-07-05</td>\n",
       "      <td>4</td>\n",
       "      <td>400195.0</td>\n",
       "      <td>0.071099</td>\n",
       "      <td>0.003232</td>\n",
       "      <td>0.004617</td>\n",
       "      <td>1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S13259</th>\n",
       "      <td>2019-06-01</td>\n",
       "      <td>6</td>\n",
       "      <td>645925.0</td>\n",
       "      <td>0.025854</td>\n",
       "      <td>0.011542</td>\n",
       "      <td>0.011080</td>\n",
       "      <td>1.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S12463</th>\n",
       "      <td>2019-04-11</td>\n",
       "      <td>7</td>\n",
       "      <td>345919.0</td>\n",
       "      <td>0.005540</td>\n",
       "      <td>0.022622</td>\n",
       "      <td>0.000923</td>\n",
       "      <td>0.8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1083 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         最近一次购买时间  消费频率        消费金额         R         F         M  score\n",
       "客户编码                                                                    \n",
       "S17476 2019-09-30    69  10325832.0  0.980148  0.986611  0.987073   98.6\n",
       "S22326 2019-09-30    62  10074609.0  0.980148  0.973223  0.984303   98.0\n",
       "S11581 2019-09-28    79  10333668.0  0.918283  0.996768  0.987996   97.7\n",
       "S12848 2019-09-29    66   9673572.0  0.944598  0.980609  0.980609   97.3\n",
       "S19095 2019-09-26    81  11031632.0  0.864728  0.999077  0.996307   97.1\n",
       "...           ...   ...         ...       ...       ...       ...    ...\n",
       "S12690 2019-05-07     7    917233.0  0.012927  0.022622  0.024931    2.2\n",
       "S11176 2019-06-09     7    614134.0  0.036011  0.022622  0.009234    1.9\n",
       "S18379 2019-07-05     4    400195.0  0.071099  0.003232  0.004617    1.7\n",
       "S13259 2019-06-01     6    645925.0  0.025854  0.011542  0.011080    1.4\n",
       "S12463 2019-04-11     7    345919.0  0.005540  0.022622  0.000923    0.8\n",
       "\n",
       "[1083 rows x 7 columns]"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_rfm['score'] = data_rfm['R'] * 20 + data_rfm['F'] * 30 + data_rfm['M'] * 50\n",
    "data_rfm['score'] = data_rfm['score'].round(1)\n",
    "data_rfm.sort_values(by='score', ascending=False)  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fixed-turkish",
   "metadata": {},
   "source": [
    "根据这个分数结果，我们可以对客户打上一些标签，比如大于 80 分的，标志为优质客户，在资源有限的情况下，可以优先服务好优质客户。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "384px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
