{"id":4073,"date":"2025-10-17T17:46:44","date_gmt":"2025-10-17T09:46:44","guid":{"rendered":"http:\/\/viplao.com\/?p=4073"},"modified":"2025-10-18T11:38:17","modified_gmt":"2025-10-18T03:38:17","slug":"%e3%80%90%e8%bf%90%e8%90%a5%e6%95%b0%e6%8d%ae%e5%88%86%e6%9e%90-%e5%9f%ba%e7%a1%80%e7%af%87%e3%80%91%e7%94%b5%e5%95%86%e8%bf%90%e8%90%a5%e6%95%b0%e6%8d%ae%e5%9f%ba%e7%a1%80%e5%88%86%e6%9e%90%e5%ae%9e","status":"publish","type":"post","link":"http:\/\/viplao.com\/index.php\/2025\/10\/17\/%e3%80%90%e8%bf%90%e8%90%a5%e6%95%b0%e6%8d%ae%e5%88%86%e6%9e%90-%e5%9f%ba%e7%a1%80%e7%af%87%e3%80%91%e7%94%b5%e5%95%86%e8%bf%90%e8%90%a5%e6%95%b0%e6%8d%ae%e5%9f%ba%e7%a1%80%e5%88%86%e6%9e%90%e5%ae%9e\/","title":{"rendered":"\u3010\u8fd0\u8425\u6570\u636e\u5206\u6790-\u57fa\u7840\u7bc7\u3011\u7535\u5546\u8fd0\u8425\u6570\u636e\u57fa\u7840\u5206\u6790\u5b9e\u4f8b"},"content":{"rendered":"\n<p><strong>\u3010\u7406\u8bba\u8bb2\u89e3\u3011<\/strong><\/p>\n\n\n\n<p>\u6709\u4e86\u6570\u636e\u5904\u7406\u548c\u53ef\u89c6\u5316\u7684\u80fd\u529b\uff0c\u6211\u4eec\u73b0\u5728\u53ef\u4ee5\u5f00\u59cb\u8fdb\u884c\u771f\u6b63\u7684\u7535\u5546\u6570\u636e\u5206\u6790\u4e86\u3002\u672c\u7ae0\u5c06\u5b66\u4e60\u5982\u4f55\u8fd0\u7528\u63cf\u8ff0\u6027\u7edf\u8ba1\u91cf\u6765\u6982\u62ec\u6570\u636e\u7279\u5f81\uff0c\u5e76\u901a\u8fc7\u4e00\u4e2a\u8ba2\u5355\u6570\u636e\u7684\u7efc\u5408\u6848\u4f8b\uff0c\u5c06\u524d\u9762\u6240\u5b66\u878d\u4f1a\u8d2f\u901a\uff0c\u4ea7\u51fa\u521d\u6b65\u7684\u8fd0\u8425\u6d1e\u5bdf\u3002<\/p>\n\n\n\n<ul>\n<li><strong>\u63cf\u8ff0\u6027\u7edf\u8ba1\uff1a<\/strong>&nbsp;\u901a\u8fc7\u8ba1\u7b97\u5747\u503c\u3001\u4e2d\u4f4d\u6570\u3001\u4f17\u6570\u3001\u6807\u51c6\u5dee\u7b49\uff0c\u6765\u7406\u89e3\u6570\u636e\u7684\u4e2d\u5fc3\u8d8b\u52bf\u3001\u79bb\u6563\u7a0b\u5ea6\u548c\u5206\u5e03\u5f62\u6001\u3002<\/li>\n\n\n\n<li><strong>\u5206\u4f4d\u6570\u4e0e\u7bb1\u7ebf\u56fe\uff1a<\/strong>&nbsp;\u5e2e\u52a9\u6211\u4eec\u4e86\u89e3\u6570\u636e\u7684\u5206\u5e03\u8303\u56f4\u548c\u5f02\u5e38\u503c\u3002<\/li>\n\n\n\n<li><strong>\u8ba2\u5355\u6570\u636e\u6982\u89c8\uff1a<\/strong>&nbsp;\u5b9e\u9645\u64cd\u4f5c\uff0c\u8ba1\u7b97\u5173\u952e\u6307\u6807\uff0c\u5e76\u7528\u56fe\u8868\u5c55\u793a\u5206\u6790\u7ed3\u679c\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u3010\u63d0\u4f9b\u6570\u636e\u96c6\u3011<\/strong><\/p>\n\n\n\n<p>\u7ee7\u7eed\u4f7f\u7528&nbsp;<code>ecommerce_orders.csv<\/code>\u3002<\/p>\n\n\n\n<p><strong>\u3010\u4ee3\u7801\u5b9e\u4f8b\u4e0e\u7535\u5546\u573a\u666f\u6848\u4f8b\u3011<\/strong><\/p>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n# \u8bbe\u7f6e\u4e2d\u6587\u663e\u793a\u548c\u8d1f\u53f7\u6b63\u5e38\u663e\u793a\nplt.rcParams&#91;'font.sans-serif'] = &#91;'SimHei']\nplt.rcParams&#91;'axes.unicode_minus'] = False\n\n# \u52a0\u8f7d\u7535\u5546\u8ba2\u5355\u6570\u636e\ndf_orders = pd.read_csv('ecommerce_orders.csv')\ndf_orders&#91;'order_date'] = pd.to_datetime(df_orders&#91;'order_date'])\ndf_orders&#91;'total_amount'] = df_orders&#91;'price'] * df_orders&#91;'quantity']\n\nprint(\"\u7528\u4e8e\u57fa\u7840\u5206\u6790\u7684\u8ba2\u5355\u6570\u636e\u9884\u89c8:\\n\", df_orders.head())\n\n# --- 4.1 \u63cf\u8ff0\u6027\u7edf\u8ba1\u5206\u6790 ---\nprint(\"\\n--- \u63cf\u8ff0\u6027\u7edf\u8ba1\u5206\u6790 ---\")\n\n# \u7535\u5546\u573a\u666f\uff1a\u67e5\u770b\u8ba2\u5355\u603b\u91d1\u989d\u7684\u7edf\u8ba1\u6458\u8981\nprint(\"\\n\u8ba2\u5355\u603b\u91d1\u989d (total_amount) \u7684\u63cf\u8ff0\u6027\u7edf\u8ba1:\\n\", df_orders&#91;'total_amount'].describe())\n# \u89e3\u91ca\uff1a\n# count: \u8ba2\u5355\u6570\u91cf\n# mean: \u5e73\u5747\u8ba2\u5355\u91d1\u989d\n# std: \u8ba2\u5355\u91d1\u989d\u7684\u6807\u51c6\u5dee (\u8861\u91cf\u6ce2\u52a8\u6027)\n# min: \u6700\u5c0f\u8ba2\u5355\u91d1\u989d\n# 25%, 50%, 75%: \u56db\u5206\u4f4d\u6570 (50%\u662f\u4e2d\u4f4d\u6570)\n# max: \u6700\u5927\u8ba2\u5355\u91d1\u989d\n\n# \u7535\u5546\u573a\u666f\uff1a\u67e5\u770b\u5546\u54c1\u4ef7\u683c\u7684\u5206\u5e03\nprint(\"\\n\u5546\u54c1\u5355\u4ef7 (price) \u7684\u63cf\u8ff0\u6027\u7edf\u8ba1:\\n\", df_orders&#91;'price'].describe())\n\n# \u4f17\u6570 (\u6700\u5e38\u89c1\u7684\u503c)\nprint(\"\\n\u6700\u5e38\u89c1\u7684\u5546\u54c1\u7c7b\u522b:\", df_orders&#91;'category'].mode()&#91;0])\nprint(\"\u6700\u5e38\u89c1\u7684\u652f\u4ed8\u65b9\u5f0f:\", df_orders&#91;'payment_method'].mode()&#91;0])\n\n# \u53ef\u89c6\u5316\u5206\u5e03\uff1a\u76f4\u65b9\u56fe\u548c\u7bb1\u7ebf\u56fe\nplt.figure(figsize=(12, 5))\n\nplt.subplot(1, 2, 1) # \u7ed8\u5236\u7b2c\u4e00\u4e2a\u5b50\u56fe\nsns.histplot(df_orders&#91;'total_amount'], bins=10, kde=True) # \u76f4\u65b9\u56fe\uff0ckde\u663e\u793a\u6838\u5bc6\u5ea6\u4f30\u8ba1\nplt.title('\u8ba2\u5355\u603b\u91d1\u989d\u5206\u5e03\u76f4\u65b9\u56fe')\nplt.xlabel('\u8ba2\u5355\u603b\u91d1\u989d (\u5143)')\nplt.ylabel('\u8ba2\u5355\u6570\u91cf')\n\nplt.subplot(1, 2, 2) # \u7ed8\u5236\u7b2c\u4e8c\u4e2a\u5b50\u56fe\nsns.boxplot(y=df_orders&#91;'total_amount']) # \u7bb1\u7ebf\u56fe\nplt.title('\u8ba2\u5355\u603b\u91d1\u989d\u7bb1\u7ebf\u56fe')\nplt.ylabel('\u8ba2\u5355\u603b\u91d1\u989d (\u5143)')\n\nplt.tight_layout()\nplt.show()\n# \u89e3\u91ca\u7bb1\u7ebf\u56fe\uff1a\u4e2d\u95f4\u7684\u7ebf\u662f\u4e2d\u4f4d\u6570\uff0c\u7bb1\u5b50\u7684\u4e0a\u4e0b\u8fb9\u754c\u662f25%\u548c75%\u5206\u4f4d\u6570\uff0c\n# \u987b\uff08\u7ebf\uff09\u7684\u672b\u7aef\u8868\u793a\u6570\u636e\u7684\u5927\u81f4\u8303\u56f4\uff0c\u8d85\u51fa\u987b\u7684\u70b9\u901a\u5e38\u88ab\u8ba4\u4e3a\u662f\u5f02\u5e38\u503c\u3002\n\n\n# --- 4.2 \u6848\u4f8b\u5206\u6790\uff1a\u8ba2\u5355\u6570\u636e\u6982\u89c8 ---\nprint(\"\\n\\n--- \u6848\u4f8b\u5206\u6790\uff1a\u8ba2\u5355\u6570\u636e\u6982\u89c8 ---\")\n\n# 1. \u8ba1\u7b97\u603b\u9500\u552e\u989d\u3001\u603b\u8ba2\u5355\u91cf\u3001\u5e73\u5747\u8ba2\u5355\u91d1\u989d\ntotal_sales = df_orders&#91;'total_amount'].sum()\ntotal_orders = df_orders&#91;'order_id'].nunique() # \u7edf\u8ba1\u4e0d\u91cd\u590d\u7684\u8ba2\u5355ID\navg_order_value = total_sales \/ total_orders\n\nprint(f\"\\n\u603b\u9500\u552e\u989d: {total_sales:.2f} \u5143\")\nprint(f\"\u603b\u8ba2\u5355\u91cf: {total_orders} \u5355\")\nprint(f\"\u5e73\u5747\u8ba2\u5355\u91d1\u989d: {avg_order_value:.2f} \u5143\")\n\n# 2. \u6309\u65f6\u95f4\u7ef4\u5ea6\u7edf\u8ba1\u9500\u552e\u8d8b\u52bf (\u65e5\u3001\u5468)\n# \u6bcf\u65e5\u9500\u552e\u989d\ndaily_sales_trend = df_orders.groupby('order_date')&#91;'total_amount'].sum()\n\n# \u6dfb\u52a0\u5468\u6570\uff0c\u6309\u5468\u7edf\u8ba1\u9500\u552e\u989d\ndf_orders&#91;'order_week'] = df_orders&#91;'order_date'].dt.isocalendar().week.astype(int) # \u83b7\u53d6\u5468\u6570\nweekly_sales_trend = df_orders.groupby('order_week')&#91;'total_amount'].sum()\n\nplt.figure(figsize=(15, 6))\n\nplt.subplot(1, 2, 1)\nsns.lineplot(x=daily_sales_trend.index, y=daily_sales_trend.values, marker='o')\nplt.title('\u6bcf\u65e5\u9500\u552e\u989d\u8d8b\u52bf')\nplt.xlabel('\u65e5\u671f')\nplt.ylabel('\u9500\u552e\u989d (\u5143)')\nplt.xticks(rotation=45)\n\nplt.subplot(1, 2, 2)\nsns.barplot(x=weekly_sales_trend.index, y=weekly_sales_trend.values)\nplt.title('\u6bcf\u5468\u9500\u552e\u989d\u8d8b\u52bf')\nplt.xlabel('\u5468\u6570')\nplt.ylabel('\u9500\u552e\u989d (\u5143)')\n\nplt.tight_layout()\nplt.show()\n\n# 3. \u5546\u54c1\u9500\u552e\u91cf\/\u989d Top N \u5206\u6790\n# Top 5 \u7545\u9500\u5546\u54c1 (\u6309\u9500\u91cf)\ntop_selling_products_qty = df_orders.groupby('product_name')&#91;'quantity'].sum().nlargest(5)\nprint(\"\\nTop 5 \u7545\u9500\u5546\u54c1 (\u6309\u9500\u91cf):\\n\", top_selling_products_qty)\n\n# Top 5 \u7545\u9500\u5546\u54c1 (\u6309\u9500\u552e\u989d)\ntop_selling_products_revenue = df_orders.groupby('product_name')&#91;'total_amount'].sum().nlargest(5)\nprint(\"\\nTop 5 \u7545\u9500\u5546\u54c1 (\u6309\u9500\u552e\u989d):\\n\", top_selling_products_revenue)\n\nplt.figure(figsize=(15, 6))\n\nplt.subplot(1, 2, 1)\nsns.barplot(x=top_selling_products_qty.index, y=top_selling_products_qty.values, palette='viridis')\nplt.title('Top 5 \u7545\u9500\u5546\u54c1 (\u6309\u9500\u91cf)')\nplt.xlabel('\u5546\u54c1\u540d\u79f0')\nplt.ylabel('\u603b\u9500\u91cf')\nplt.xticks(rotation=45, ha='right')\n\nplt.subplot(1, 2, 2)\nsns.barplot(x=top_selling_products_revenue.index, y=top_selling_products_revenue.values, palette='magma')\nplt.title('Top 5 \u7545\u9500\u5546\u54c1 (\u6309\u9500\u552e\u989d)')\nplt.xlabel('\u5546\u54c1\u540d\u79f0')\nplt.ylabel('\u603b\u9500\u552e\u989d (\u5143)')\nplt.xticks(rotation=45, ha='right')\n\nplt.tight_layout()\nplt.show()\n\n# 4. \u7528\u6237\u6d88\u8d39\u91d1\u989d\u5206\u5e03\n# \u7edf\u8ba1\u6bcf\u4e2a\u7528\u6237\u7684\u603b\u6d88\u8d39\u91d1\u989d\nuser_total_spent = df_orders.groupby('user_id')&#91;'total_amount'].sum().sort_values(ascending=False)\nprint(\"\\nTop 10 \u6d88\u8d39\u7528\u6237:\\n\", user_total_spent.head(10))\n\nplt.figure(figsize=(10, 6))\nsns.histplot(user_total_spent, bins=10, kde=True)\nplt.title('\u7528\u6237\u603b\u6d88\u8d39\u91d1\u989d\u5206\u5e03')\nplt.xlabel('\u7528\u6237\u603b\u6d88\u8d39\u91d1\u989d (\u5143)')\nplt.ylabel('\u7528\u6237\u6570\u91cf')\nplt.show()\n\n# 5. \u5404\u57ce\u5e02\u9500\u552e\u989d\u5bf9\u6bd4\ncity_sales = df_orders.groupby('shipping_city')&#91;'total_amount'].sum().sort_values(ascending=False)\nprint(\"\\n\u5404\u57ce\u5e02\u603b\u9500\u552e\u989d:\\n\", city_sales)\n\nplt.figure(figsize=(10, 6))\nsns.barplot(x=city_sales.index, y=city_sales.values, palette='rocket')\nplt.title('\u5404\u57ce\u5e02\u603b\u9500\u552e\u989d')\nplt.xlabel('\u57ce\u5e02')\nplt.ylabel('\u603b\u9500\u552e\u989d (\u5143)')\nplt.xticks(rotation=45, ha='right')\nplt.tight_layout()\nplt.show()<\/code><\/pre>\n\n\n\n<p><strong>\u3010\u4e92\u52a8\u95ee\u7b54\u3011<\/strong><\/p>\n\n\n\n<ul>\n<li>\u5728\u7535\u5546\u8fd0\u8425\u4e2d\uff0c\u54ea\u4e9b\u63cf\u8ff0\u6027\u7edf\u8ba1\u91cf\u5bf9\u4f60\u6700\u6709\u4ef7\u503c\uff1f\u4e3a\u4ec0\u4e48\uff1f<\/li>\n\n\n\n<li>\u76f4\u65b9\u56fe\u548c\u7bb1\u7ebf\u56fe\u5728\u5206\u6790\u8ba2\u5355\u91d1\u989d\u5206\u5e03\u65f6\u5404\u6709\u4ec0\u4e48\u4f18\u7f3a\u70b9\uff1f<\/li>\n\n\n\n<li>\u5982\u4f55\u6839\u636e\u6bcf\u65e5\u9500\u552e\u989d\u8d8b\u52bf\u56fe\uff0c\u53d1\u73b0\u53ef\u80fd\u7684\u9500\u552e\u9ad8\u5cf0\u6216\u4f4e\u8c37\uff1f<\/li>\n\n\n\n<li>Top N \u5546\u54c1\u5206\u6790\u5bf9\u8fd0\u8425\u51b3\u7b56\u6709\u4ec0\u4e48\u6307\u5bfc\u610f\u4e49\uff1f<\/li>\n\n\n\n<li>\u5982\u679c\u53d1\u73b0\u67d0\u4e2a\u57ce\u5e02\u7684\u9500\u552e\u989d\u5f02\u5e38\u9ad8\u6216\u4f4e\uff0c\u4f60\u4e0b\u4e00\u6b65\u4f1a\u600e\u4e48\u505a\uff1f<\/li>\n\n\n\n<li>\u5982\u4f55\u8ba1\u7b97\u7528\u6237\u7684\u5e73\u5747\u8d2d\u4e70\u9891\u7387\uff08\u5373\u591a\u5c11\u5929\u8d2d\u4e70\u4e00\u6b21\uff09\uff1f<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u3010\u7406\u8bba\u8bb2\u89e3\u3011 \u6709\u4e86\u6570\u636e\u5904\u7406\u548c\u53ef\u89c6\u5316\u7684\u80fd\u529b\uff0c\u6211\u4eec\u73b0\u5728\u53ef\u4ee5\u5f00\u59cb\u8fdb\u884c\u771f\u6b63\u7684\u7535\u5546\u6570\u636e\u5206\u6790\u4e86\u3002\u672c\u7ae0\u5c06\u5b66\u4e60\u5982\u4f55\u8fd0&hellip; <a href=\"http:\/\/viplao.com\/index.php\/2025\/10\/17\/%e3%80%90%e8%bf%90%e8%90%a5%e6%95%b0%e6%8d%ae%e5%88%86%e6%9e%90-%e5%9f%ba%e7%a1%80%e7%af%87%e3%80%91%e7%94%b5%e5%95%86%e8%bf%90%e8%90%a5%e6%95%b0%e6%8d%ae%e5%9f%ba%e7%a1%80%e5%88%86%e6%9e%90%e5%ae%9e\/\" class=\"more-link read-more\" rel=\"bookmark\">\u7ee7\u7eed\u9605\u8bfb <span class=\"screen-reader-text\">\u3010\u8fd0\u8425\u6570\u636e\u5206\u6790-\u57fa\u7840\u7bc7\u3011\u7535\u5546\u8fd0\u8425\u6570\u636e\u57fa\u7840\u5206\u6790\u5b9e\u4f8b<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[28],"views":554,"_links":{"self":[{"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/posts\/4073"}],"collection":[{"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/comments?post=4073"}],"version-history":[{"count":3,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/posts\/4073\/revisions"}],"predecessor-version":[{"id":4091,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/posts\/4073\/revisions\/4091"}],"wp:attachment":[{"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/media?parent=4073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/categories?post=4073"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/tags?post=4073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}