{"id":1050692,"date":"2024-12-31T14:10:02","date_gmt":"2024-12-31T06:10:02","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1050692.html"},"modified":"2024-12-31T14:10:04","modified_gmt":"2024-12-31T06:10:04","slug":"python%e5%a6%82%e4%bd%95%e8%af%bb%e5%8f%96%e8%a1%a8%e6%a0%bc%e7%9a%84%e6%95%b0%e6%8d%ae%e5%b9%b6%e4%bd%9c%e5%9b%be","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1050692.html","title":{"rendered":"python\u5982\u4f55\u8bfb\u53d6\u8868\u683c\u7684\u6570\u636e\u5e76\u4f5c\u56fe"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/5e2c1275-55b8-4bfd-8a95-f969cf8c4d14.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u5982\u4f55\u8bfb\u53d6\u8868\u683c\u7684\u6570\u636e\u5e76\u4f5c\u56fe\" \/><\/p>\n<p><p> <strong>Python\u8bfb\u53d6\u8868\u683c\u7684\u6570\u636e\u5e76\u4f5c\u56fe\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528Pandas\u5e93\u8bfb\u53d6\u6570\u636e\u3001\u4f7f\u7528Matplotlib\u6216Seaborn\u5e93\u8fdb\u884c\u4f5c\u56fe\u3002<\/strong>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u5e93\u6765\u8bfb\u53d6\u8868\u683c\u6570\u636e\u5e76\u8fdb\u884c\u53ef\u89c6\u5316\uff0c<strong>\u5177\u4f53\u5305\u62ec\u5982\u4f55\u8bfb\u53d6Excel\u6587\u4ef6\u3001CSV\u6587\u4ef6\u4ee5\u53ca\u5982\u4f55\u8fdb\u884c\u6570\u636e\u6e05\u6d17\u548c\u5904\u7406\uff0c\u6700\u540e\u4f7f\u7528\u4e0d\u540c\u7684\u53ef\u89c6\u5316\u5e93\u8fdb\u884c\u56fe\u5f62\u7ed8\u5236\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u3001PANDAS\u5e93\u8bfb\u53d6\u8868\u683c\u6570\u636e<\/p>\n<\/p>\n<p><p>Pandas\u662f\u4e00\u4e2a\u5f3a\u5927\u7684Python\u6570\u636e\u5206\u6790\u5e93\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u4fbf\u6377\u7684\u65b9\u6cd5\u6765\u8bfb\u53d6\u548c\u64cd\u4f5c\u8868\u683c\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u8bfb\u53d6CSV\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>CSV\u6587\u4ef6\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0cPandas\u63d0\u4f9b\u4e86<code>read_csv<\/code>\u51fd\u6570\u6765\u8bfb\u53d6CSV\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u8bfb\u53d6CSV\u6587\u4ef6<\/strong><\/h2>\n<p>data = pd.read_csv(&#39;data.csv&#39;)<\/p>\n<h2><strong>\u663e\u793a\u524d5\u884c\u6570\u636e<\/strong><\/h2>\n<p>print(data.head())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>pd.read_csv<\/code>\u51fd\u6570\u8bfb\u53d6\u4e86\u540d\u4e3a<code>data.csv<\/code>\u7684\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u5b58\u50a8\u5728\u53d8\u91cf<code>data<\/code>\u4e2d\u3002\u7136\u540e\uff0c\u4f7f\u7528<code>head<\/code>\u65b9\u6cd5\u67e5\u770b\u6570\u636e\u7684\u524d\u4e94\u884c\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u8bfb\u53d6Excel\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>Excel\u6587\u4ef6\u4e5f\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0cPandas\u63d0\u4f9b\u4e86<code>read_excel<\/code>\u51fd\u6570\u6765\u8bfb\u53d6Excel\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6Excel\u6587\u4ef6<\/p>\n<p>data = pd.read_excel(&#39;data.xlsx&#39;)<\/p>\n<h2><strong>\u663e\u793a\u524d5\u884c\u6570\u636e<\/strong><\/h2>\n<p>print(data.head())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>pd.read_excel<\/code>\u51fd\u6570\u8bfb\u53d6\u4e86\u540d\u4e3a<code>data.xlsx<\/code>\u7684\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u5b58\u50a8\u5728\u53d8\u91cf<code>data<\/code>\u4e2d\u3002\u7136\u540e\uff0c\u4f7f\u7528<code>head<\/code>\u65b9\u6cd5\u67e5\u770b\u6570\u636e\u7684\u524d\u4e94\u884c\u3002<\/p>\n<\/p>\n<p><h3>3\u3001\u6570\u636e\u6e05\u6d17\u548c\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u5728\u8bfb\u53d6\u6570\u636e\u540e\uff0c\u6211\u4eec\u901a\u5e38\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u6e05\u6d17\u548c\u5904\u7406\u3002\u4f8b\u5982\uff0c\u53bb\u9664\u7f3a\u5931\u503c\u3001\u8f6c\u6362\u6570\u636e\u7c7b\u578b\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u53bb\u9664\u5305\u542b\u7f3a\u5931\u503c\u7684\u884c<\/p>\n<p>data = data.dropna()<\/p>\n<h2><strong>\u5c06\u67d0\u5217\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u4e3a\u6574\u6570<\/strong><\/h2>\n<p>data[&#39;column_name&#39;] = data[&#39;column_name&#39;].astype(int)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>dropna<\/code>\u65b9\u6cd5\u53bb\u9664\u4e86\u5305\u542b\u7f3a\u5931\u503c\u7684\u884c\uff0c\u5e76\u4f7f\u7528<code>astype<\/code>\u65b9\u6cd5\u5c06\u67d0\u5217\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u4e3a\u6574\u6570\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001MATPLOTLIB\u5e93\u4f5c\u56fe<\/p>\n<\/p>\n<p><p>Matplotlib\u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u7ed8\u56fe\u5e93\u4e4b\u4e00\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u57fa\u7840\u7684\u7ed8\u56fe\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u7ed8\u5236\u6298\u7ebf\u56fe<\/h3>\n<\/p>\n<p><p>\u6298\u7ebf\u56fe\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u6570\u636e\u53ef\u89c6\u5316\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5c55\u793a\u6570\u636e\u7684\u53d8\u5316\u8d8b\u52bf\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u7ed8\u5236\u6298\u7ebf\u56fe<\/strong><\/h2>\n<p>plt.plot(data[&#39;x&#39;], data[&#39;y&#39;])<\/p>\n<p>plt.xlabel(&#39;X\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.ylabel(&#39;Y\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.title(&#39;\u6298\u7ebf\u56fe\u6807\u9898&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>plt.plot<\/code>\u51fd\u6570\u7ed8\u5236\u4e86\u6298\u7ebf\u56fe\uff0c\u5e76\u4f7f\u7528<code>xlabel<\/code>\u3001<code>ylabel<\/code>\u548c<code>title<\/code>\u51fd\u6570\u8bbe\u7f6e\u4e86X\u8f74\u6807\u7b7e\u3001Y\u8f74\u6807\u7b7e\u548c\u56fe\u8868\u6807\u9898\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u7ed8\u5236\u67f1\u72b6\u56fe<\/h3>\n<\/p>\n<p><p>\u67f1\u72b6\u56fe\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u6570\u636e\u53ef\u89c6\u5316\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5c55\u793a\u4e0d\u540c\u7c7b\u522b\u7684\u6570\u636e\u5206\u5e03\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236\u67f1\u72b6\u56fe<\/p>\n<p>plt.bar(data[&#39;x&#39;], data[&#39;y&#39;])<\/p>\n<p>plt.xlabel(&#39;X\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.ylabel(&#39;Y\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.title(&#39;\u67f1\u72b6\u56fe\u6807\u9898&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>plt.bar<\/code>\u51fd\u6570\u7ed8\u5236\u4e86\u67f1\u72b6\u56fe\uff0c\u5e76\u4f7f\u7528<code>xlabel<\/code>\u3001<code>ylabel<\/code>\u548c<code>title<\/code>\u51fd\u6570\u8bbe\u7f6e\u4e86X\u8f74\u6807\u7b7e\u3001Y\u8f74\u6807\u7b7e\u548c\u56fe\u8868\u6807\u9898\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001SEABORN\u5e93\u4f5c\u56fe<\/p>\n<\/p>\n<p><p>Seaborn\u662f\u57fa\u4e8eMatplotlib\u7684\u9ad8\u7ea7\u7ed8\u56fe\u5e93\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u7f8e\u89c2\u7684\u9ed8\u8ba4\u6837\u5f0f\u548c\u9ad8\u7ea7\u7ed8\u56fe\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u7ed8\u5236\u6563\u70b9\u56fe<\/h3>\n<\/p>\n<p><p>\u6563\u70b9\u56fe\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u6570\u636e\u53ef\u89c6\u5316\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5c55\u793a\u4e24\u4e2a\u53d8\u91cf\u4e4b\u95f4\u7684\u5173\u7cfb\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import seaborn as sns<\/p>\n<h2><strong>\u7ed8\u5236\u6563\u70b9\u56fe<\/strong><\/h2>\n<p>sns.scatterplot(x=&#39;x&#39;, y=&#39;y&#39;, data=data)<\/p>\n<p>plt.xlabel(&#39;X\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.ylabel(&#39;Y\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.title(&#39;\u6563\u70b9\u56fe\u6807\u9898&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>sns.scatterplot<\/code>\u51fd\u6570\u7ed8\u5236\u4e86\u6563\u70b9\u56fe\uff0c\u5e76\u4f7f\u7528<code>xlabel<\/code>\u3001<code>ylabel<\/code>\u548c<code>title<\/code>\u51fd\u6570\u8bbe\u7f6e\u4e86X\u8f74\u6807\u7b7e\u3001Y\u8f74\u6807\u7b7e\u548c\u56fe\u8868\u6807\u9898\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u7ed8\u5236\u7bb1\u7ebf\u56fe<\/h3>\n<\/p>\n<p><p>\u7bb1\u7ebf\u56fe\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u6570\u636e\u53ef\u89c6\u5316\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5c55\u793a\u6570\u636e\u7684\u5206\u5e03\u60c5\u51b5\u548c\u79bb\u7fa4\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236\u7bb1\u7ebf\u56fe<\/p>\n<p>sns.boxplot(x=&#39;\u5206\u7c7b\u53d8\u91cf&#39;, y=&#39;\u6570\u503c\u53d8\u91cf&#39;, data=data)<\/p>\n<p>plt.xlabel(&#39;X\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.ylabel(&#39;Y\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.title(&#39;\u7bb1\u7ebf\u56fe\u6807\u9898&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>sns.boxplot<\/code>\u51fd\u6570\u7ed8\u5236\u4e86\u7bb1\u7ebf\u56fe\uff0c\u5e76\u4f7f\u7528<code>xlabel<\/code>\u3001<code>ylabel<\/code>\u548c<code>title<\/code>\u51fd\u6570\u8bbe\u7f6e\u4e86X\u8f74\u6807\u7b7e\u3001Y\u8f74\u6807\u7b7e\u548c\u56fe\u8868\u6807\u9898\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u7efc\u5408\u5b9e\u4f8b<\/p>\n<\/p>\n<p><h3>1\u3001\u8bfb\u53d6\u8868\u683c\u6570\u636e\u5e76\u4f5c\u56fe<\/h3>\n<\/p>\n<p><p>\u5728\u8fd9\u4e00\u90e8\u5206\uff0c\u6211\u4eec\u5c06\u7ed3\u5408\u4e0a\u8ff0\u5185\u5bb9\uff0c\u901a\u8fc7\u4e00\u4e2a\u7efc\u5408\u5b9e\u4f8b\u6765\u5c55\u793a\u5982\u4f55\u8bfb\u53d6\u8868\u683c\u6570\u636e\u5e76\u8fdb\u884c\u53ef\u89c6\u5316\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>import seaborn as sns<\/p>\n<h2><strong>\u8bfb\u53d6CSV\u6587\u4ef6<\/strong><\/h2>\n<p>data = pd.read_csv(&#39;data.csv&#39;)<\/p>\n<h2><strong>\u6570\u636e\u6e05\u6d17\u548c\u5904\u7406<\/strong><\/h2>\n<p>data = data.dropna()<\/p>\n<p>data[&#39;column_name&#39;] = data[&#39;column_name&#39;].astype(int)<\/p>\n<h2><strong>\u7ed8\u5236\u6298\u7ebf\u56fe<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(data[&#39;x&#39;], data[&#39;y&#39;], label=&#39;\u6298\u7ebf\u56fe&#39;)<\/p>\n<p>plt.xlabel(&#39;X\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.ylabel(&#39;Y\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.title(&#39;\u6298\u7ebf\u56fe\u6807\u9898&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<h2><strong>\u7ed8\u5236\u67f1\u72b6\u56fe<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.bar(data[&#39;x&#39;], data[&#39;y&#39;], label=&#39;\u67f1\u72b6\u56fe&#39;)<\/p>\n<p>plt.xlabel(&#39;X\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.ylabel(&#39;Y\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.title(&#39;\u67f1\u72b6\u56fe\u6807\u9898&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<h2><strong>\u7ed8\u5236\u6563\u70b9\u56fe<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>sns.scatterplot(x=&#39;x&#39;, y=&#39;y&#39;, data=data, label=&#39;\u6563\u70b9\u56fe&#39;)<\/p>\n<p>plt.xlabel(&#39;X\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.ylabel(&#39;Y\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.title(&#39;\u6563\u70b9\u56fe\u6807\u9898&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<h2><strong>\u7ed8\u5236\u7bb1\u7ebf\u56fe<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>sns.boxplot(x=&#39;\u5206\u7c7b\u53d8\u91cf&#39;, y=&#39;\u6570\u503c\u53d8\u91cf&#39;, data=data)<\/p>\n<p>plt.xlabel(&#39;X\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.ylabel(&#39;Y\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.title(&#39;\u7bb1\u7ebf\u56fe\u6807\u9898&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u4f7f\u7528Pandas\u5e93\u8bfb\u53d6CSV\u6587\u4ef6\uff0c\u5e76\u5bf9\u6570\u636e\u8fdb\u884c\u6e05\u6d17\u548c\u5904\u7406\u3002\u7136\u540e\uff0c\u5206\u522b\u4f7f\u7528Matplotlib\u548cSeaborn\u5e93\u7ed8\u5236\u4e86\u6298\u7ebf\u56fe\u3001\u67f1\u72b6\u56fe\u3001\u6563\u70b9\u56fe\u548c\u7bb1\u7ebf\u56fe\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u7ed3\u5408\u591a\u4e2a\u56fe\u8868\u8fdb\u884c\u6570\u636e\u5206\u6790<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u6570\u636e\u5206\u6790\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u9700\u8981\u7ed3\u5408\u591a\u4e2a\u56fe\u8868\u6765\u7efc\u5408\u5206\u6790\u6570\u636e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236\u6298\u7ebf\u56fe\u548c\u6563\u70b9\u56fe\u7ed3\u5408<\/p>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(data[&#39;x&#39;], data[&#39;y&#39;], label=&#39;\u6298\u7ebf\u56fe&#39;)<\/p>\n<p>sns.scatterplot(x=&#39;x&#39;, y=&#39;y&#39;, data=data, label=&#39;\u6563\u70b9\u56fe&#39;)<\/p>\n<p>plt.xlabel(&#39;X\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.ylabel(&#39;Y\u8f74\u6807\u7b7e&#39;)<\/p>\n<p>plt.title(&#39;\u6298\u7ebf\u56fe\u548c\u6563\u70b9\u56fe\u7ed3\u5408&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<h2><strong>\u7ed8\u5236\u67f1\u72b6\u56fe\u548c\u7bb1\u7ebf\u56fe\u7ed3\u5408<\/strong><\/h2>\n<p>fig, axes = plt.subplots(1, 2, figsize=(15, 6))<\/p>\n<p>sns.barplot(x=&#39;x&#39;, y=&#39;y&#39;, data=data, ax=axes[0])<\/p>\n<p>axes[0].set_title(&#39;\u67f1\u72b6\u56fe&#39;)<\/p>\n<p>sns.boxplot(x=&#39;\u5206\u7c7b\u53d8\u91cf&#39;, y=&#39;\u6570\u503c\u53d8\u91cf&#39;, data=data, ax=axes[1])<\/p>\n<p>axes[1].set_title(&#39;\u7bb1\u7ebf\u56fe&#39;)<\/p>\n<p>plt.suptitle(&#39;\u67f1\u72b6\u56fe\u548c\u7bb1\u7ebf\u56fe\u7ed3\u5408&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u7ed3\u5408\u4e86\u6298\u7ebf\u56fe\u548c\u6563\u70b9\u56fe\u3001\u67f1\u72b6\u56fe\u548c\u7bb1\u7ebf\u56fe\uff0c\u901a\u8fc7\u4e0d\u540c\u7684\u53ef\u89c6\u5316\u65b9\u5f0f\u6765\u7efc\u5408\u5206\u6790\u6570\u636e\uff0c\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7406\u89e3\u6570\u636e\u7684\u5206\u5e03\u548c\u8d8b\u52bf\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528Python\u8bfb\u53d6\u8868\u683c\u6570\u636e\u5e76\u8fdb\u884c\u53ef\u89c6\u5316\uff0c\u5305\u62ecPandas\u5e93\u7684\u57fa\u672c\u64cd\u4f5c\u3001Matplotlib\u548cSeaborn\u5e93\u7684\u7ed8\u56fe\u65b9\u6cd5\u4ee5\u53ca\u7efc\u5408\u5b9e\u4f8b\u3002\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u65b9\u4fbf\u5730\u8bfb\u53d6\u548c\u5206\u6790\u8868\u683c\u6570\u636e\uff0c\u5e76\u901a\u8fc7\u53ef\u89c6\u5316\u56fe\u8868\u66f4\u76f4\u89c2\u5730\u5c55\u793a\u6570\u636e\u7ed3\u679c\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u53ef\u89c6\u5316\u65b9\u6cd5\uff0c\u7ed3\u5408\u591a\u79cd\u56fe\u8868\u8fdb\u884c\u7efc\u5408\u5206\u6790\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u7406\u89e3\u548c\u5229\u7528\u6570\u636e\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u8bfb\u53d6Excel\u6587\u4ef6\u4e2d\u7684\u6570\u636e\uff1f<\/strong><br \/>Python\u63d0\u4f9b\u4e86\u591a\u4e2a\u5e93\u6765\u8bfb\u53d6Excel\u6587\u4ef6\uff0c\u5982pandas\u548copenpyxl\u3002\u4f7f\u7528pandas\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7<code>pd.read_excel(&#39;\u6587\u4ef6\u8def\u5f84&#39;)<\/code>\u8f7b\u677e\u8bfb\u53d6\u6570\u636e\uff0c\u5c06\u5176\u8f6c\u5316\u4e3aDataFrame\u683c\u5f0f\uff0c\u4fbf\u4e8e\u540e\u7eed\u7684\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u3002\u786e\u4fdd\u5b89\u88c5\u4e86pandas\u5e93\u548c\u76f8\u5e94\u7684Excel\u652f\u6301\u5e93\uff08\u5982openpyxl\u6216xlrd\uff09\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u8fdb\u884c\u6570\u636e\u53ef\u89c6\u5316\uff1f<\/strong><br \/>\u6570\u636e\u53ef\u89c6\u5316\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u5e93\u5b9e\u73b0\uff0c\u5176\u4e2dmatplotlib\u548cseaborn\u662f\u6700\u5e38\u7528\u7684\u9009\u9879\u3002\u5b89\u88c5\u8fd9\u4e9b\u5e93\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>plt.plot()<\/code>\u3001<code>sns.barplot()<\/code>\u7b49\u51fd\u6570\u6765\u521b\u5efa\u5404\u79cd\u56fe\u5f62\uff0c\u5982\u6298\u7ebf\u56fe\u3001\u67f1\u72b6\u56fe\u7b49\u3002\u901a\u8fc7\u4f20\u5165DataFrame\u4e2d\u7684\u5217\u6570\u636e\uff0c\u53ef\u4ee5\u5feb\u901f\u751f\u6210\u6240\u9700\u7684\u56fe\u8868\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u7f3a\u5931\u6570\u636e\u4ee5\u63d0\u9ad8\u7ed8\u56fe\u6548\u679c\uff1f<\/strong><br \/>\u5728\u8bfb\u53d6\u8868\u683c\u6570\u636e\u540e\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u7f3a\u5931\u503c\u3002\u53ef\u4ee5\u4f7f\u7528pandas\u7684<code>dropna()<\/code>\u65b9\u6cd5\u5220\u9664\u542b\u6709\u7f3a\u5931\u503c\u7684\u884c\uff0c\u6216\u8005\u4f7f\u7528<code>fillna()<\/code>\u65b9\u6cd5\u7528\u7279\u5b9a\u503c\u586b\u5145\u7f3a\u5931\u6570\u636e\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u751f\u6210\u7684\u56fe\u8868\u66f4\u52a0\u51c6\u786e\uff0c\u907f\u514d\u56e0\u7f3a\u5931\u6570\u636e\u5bfc\u81f4\u7684\u8bef\u89e3\u6216\u9519\u8bef\u7684\u53ef\u89c6\u5316\u7ed3\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u8bfb\u53d6\u8868\u683c\u7684\u6570\u636e\u5e76\u4f5c\u56fe\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528Pandas\u5e93\u8bfb\u53d6\u6570\u636e\u3001\u4f7f\u7528Matplotli [&hellip;]","protected":false},"author":3,"featured_media":1050694,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1050692"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1050692"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1050692\/revisions"}],"predecessor-version":[{"id":1050695,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1050692\/revisions\/1050695"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1050694"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1050692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1050692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1050692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}