{"id":235457,"date":"2022-02-14T08:06:42","date_gmt":"2022-02-14T00:06:42","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=235457"},"modified":"2022-02-08T10:07:11","modified_gmt":"2022-02-08T02:07:11","slug":"python-draw-sankey-diagram","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/python-draw-sankey-diagram.html","title":{"rendered":"Python\u7ed8\u5236\u6851\u57fa\u56fe"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u5f88\u591a\u65f6\u5019\uff0c\u6211\u4eec\u9700\u8981\u4e00\u79cd\u5fc5\u987b\u53ef\u89c6\u5316\u6570\u636e\u5982\u4f55\u5728\u5b9e\u4f53\u4e4b\u95f4\u6d41\u52a8\u7684\u60c5\u51b5\u3002\u4f8b\u5982\uff0c\u4ee5\u5c45\u6c11\u5982\u4f55\u4ece\u4e00\u4e2a\u56fd\u5bb6\u8fc1\u79fb\u5230\u53e6\u4e00\u4e2a\u56fd\u5bb6\u4e3a\u4f8b\u3002\u8fd9\u91cc\u6f14\u793a\u4e86\u6709\u591a\u5c11\u5c45\u6c11\u4ece\u82f1\u683c\u5170\u8fc1\u79fb\u5230\u5317\u7231\u5c14\u5170\u3001\u82cf\u683c\u5170\u548c\u5a01\u5c14\u58eb\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u6851\u57fa\u56fe\u7b80\u4ecb<\/strong><\/div>\n \u4ece\u8fd9\u4e2a \u6851\u57fa\u56fe (Sankey)\u53ef\u89c6\u5316\u4e2d\u53ef\u4ee5\u660e\u663e\u770b\u51fa\uff0c\u4eceEngland\u8fc1\u79fb\u5230Wales\u7684\u5c45\u6c11\u591a\u4e8e\u4eceScotland\u6216Northern Ireland\u8fc1\u79fb\u7684\u5c45\u6c11\u3002<\/p>\n <\/p>\n \u4ec0\u4e48\u662f\u6851\u57fa\u56fe?<\/strong><\/span><\/div>\n \u6851\u57fa\u56fe\u901a\u5e38\u63cf\u7ed8 \u4ece\u4e00\u4e2a\u5b9e\u4f53(\u6216\u8282\u70b9)\u5230\u53e6\u4e00\u4e2a\u5b9e\u4f53(\u6216\u8282\u70b9)\u7684\u6570\u636e\u6d41\u3002<\/p>\n \u6570\u636e\u6d41\u5411\u7684\u5b9e\u4f53\u88ab\u79f0\u4e3a\u8282\u70b9\uff0c\u6570\u636e\u6d41\u8d77\u6e90\u7684\u8282\u70b9\u662f\u6e90\u8282\u70b9(\u4f8b\u5982\u5de6\u4fa7\u7684England)\uff0c\u6d41\u7ed3\u675f\u7684\u8282\u70b9\u662f \u76ee\u6807\u8282\u70b9(\u4f8b\u5982\u53f3\u4fa7\u7684Wales)\u3002\u6e90\u8282\u70b9\u548c\u76ee\u6807\u8282\u70b9\u901a\u5e38\u8868\u793a\u4e3a\u5e26\u6709\u6807\u7b7e\u7684\u77e9\u5f62\u3002<\/p>\n \u6d41\u52a8\u672c\u8eab\u7531\u76f4\u7ebf\u6216\u66f2\u7ebf\u8def\u5f84\u8868\u793a\uff0c\u79f0\u4e3a\u94fe\u63a5\u3002\u6d41\/\u94fe\u63a5\u7684\u5bbd\u5ea6\u4e0e\u6d41\u7684\u91cf\/\u6570\u91cf\u6210\u6b63\u6bd4\u3002\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u4ece\u82f1\u683c\u5170\u5230\u5a01\u5c14\u58eb\u7684\u6d41\u52a8(\u5373\u5c45\u6c11\u8fc1\u79fb)\u6bd4\u4ece\u82f1\u683c\u5170\u5230\u82cf\u683c\u5170\u6216\u5317\u7231\u5c14\u5170\u7684\u6d41\u52a8(\u5373\u5c45\u6c11\u8fc1\u79fb)\u66f4\u5e7f\u6cdb(\u66f4\u591a)\uff0c\u8868\u660e\u8fc1\u79fb\u5230\u5a01\u5c14\u58eb\u7684\u5c45\u6c11\u6570\u91cf\u591a\u4e8e\u5176\u4ed6\u56fd\u5bb6\u3002<\/p>\n \u6851\u57fa\u56fe\u53ef\u7528\u4e8e\u8868\u793a\u80fd\u91cf\u3001\u91d1\u94b1\u3001\u6210\u672c\u7684\u6d41\u52a8\uff0c\u4ee5\u53ca\u4efb\u4f55\u5177\u6709\u6d41\u52a8\u6982\u5ff5\u7684\u4e8b\u7269\u3002<\/p>\n \u7c73\u7eb3\u5c14\u5173\u4e8e\u62ff\u7834\u4ed1\u5165\u4fb5\u4fc4\u7f57\u65af\u7684\u7ecf\u5178\u56fe\u8868\u53ef\u80fd\u662f\u6851\u57fa\u56fe\u8868\u6700\u8457\u540d\u7684\u4f8b\u5b50\u3002\u8fd9\u79cd\u4f7f\u7528\u6851\u57fa\u56fe\u7684\u53ef\u89c6\u5316\u975e\u5e38\u6709\u6548\u5730\u663e\u793a\u4e86\u6cd5\u56fd\u519b\u961f\u5728\u524d\u5f80\u4fc4\u7f57\u65af\u548c\u8fd4\u56de\u7684\u9014\u4e2d\u662f\u5982\u4f55\u8fdb\u6b65(\u6216\u51cf\u5c11?)\u7684\u3002<\/p>\n <\/p>\n \u672c\u6587\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 python \u7684 plotly \u7ed8\u5236\u6851\u57fa\u56fe\u3002<\/p>\n \u5982\u4f55\u7ed8\u5236\u6851\u57fa\u56fe?<\/strong><\/div>\n \u672c\u6587\u4f7f\u7528 2021 \u5e74\u5965\u8fd0\u4f1a\u6570\u636e\u96c6\u7ed8\u5236\u6851\u57fa\u56fe\u3002\u8be5\u6570\u636e\u96c6\u5305\u542b\u6709\u5173\u5956\u724c\u603b\u6570\u7684\u8be6\u7ec6\u4fe1\u606f\u2014\u2014\u56fd\u5bb6\u3001\u5956\u724c\u603b\u6570\u4ee5\u53ca\u91d1\u724c\u3001\u94f6\u724c\u548c\u94dc\u724c\u7684\u5355\u9879\u603b\u6570\u3002\u6211\u4eec\u901a\u8fc7\u7ed8\u5236\u4e00\u4e2a\u6851\u57fa\u56fe\u6765\u4e86\u89e3\u4e00\u4e2a\u56fd\u5bb6\u8d62\u5f97\u7684\u91d1\u724c\u3001\u94f6\u724c\u548c\u94dc\u724c\u6570\u3002<\/p>\n \r\ndf_medals = pd.read_excel(\"data\/Medals.xlsx\")\r\nprint(df_medals.info())\r\ndf_medals.rename(columns={'Team\/NOC':'Country', 'Total': 'Total Medals', 'Gold':'Gold Medals', 'Silver': 'Silver Medals', 'Bronze': 'Bronze Medals'}, inplace=True)\r\ndf_medals.drop(columns=['Unnamed: 7','Unnamed: 8','Rank by Total'], inplace=True)\r\n\r\ndf_medals\r\n<\/pre>\n\r\n |