{"id":1084061,"date":"2025-01-08T13:03:53","date_gmt":"2025-01-08T05:03:53","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1084061.html"},"modified":"2025-01-08T13:03:55","modified_gmt":"2025-01-08T05:03:55","slug":"python%e5%a6%82%e4%bd%95excel%e6%88%aa%e5%8f%96%e4%b8%80%e6%ae%b5%e5%88%97-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1084061.html","title":{"rendered":"python\u5982\u4f55excel\u622a\u53d6\u4e00\u6bb5\u5217"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24194613\/38fd59a9-7295-439c-83d5-8b4235bd0edb.webp\" alt=\"python\u5982\u4f55excel\u622a\u53d6\u4e00\u6bb5\u5217\" \/><\/p>\n<p><p> <strong>Python\u5982\u4f55\u5728Excel\u4e2d\u622a\u53d6\u4e00\u6bb5\u5217<\/strong><\/p>\n<\/p>\n<p><p>\u8981\u5728Python\u4e2d\u622a\u53d6Excel\u4e2d\u7684\u4e00\u6bb5\u5217\uff0c\u53ef\u4ee5\u4f7f\u7528<strong>pandas\u5e93\u3001\u8bfb\u53d6Excel\u6587\u4ef6\u3001\u9009\u62e9\u6240\u9700\u7684\u5217\u6570\u636e\u3001\u5904\u7406\u6570\u636e<\/strong>\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684\u6307\u5357\u548c\u793a\u4f8b\u3002<\/p>\n<\/p>\n<p><p><strong>\u4f7f\u7528pandas\u5e93\u8bfb\u53d6Excel\u6587\u4ef6\u5e76\u9009\u62e9\u5217\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>pandas\u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u6570\u636e\u5904\u7406\u5e93\u4e4b\u4e00\uff0c\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u5730\u8bfb\u53d6\u548c\u5904\u7406Excel\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528pandas\u5e93\u8bfb\u53d6Excel\u6587\u4ef6\u5e76\u622a\u53d6\u4e00\u6bb5\u5217\u6570\u636e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u8bfb\u53d6Excel\u6587\u4ef6<\/strong><\/h2>\n<p>df = pd.read_excel(&#39;example.xlsx&#39;)<\/p>\n<h2><strong>\u9009\u62e9\u6240\u9700\u7684\u5217<\/strong><\/h2>\n<p>selected_columns = df[[&#39;Column1&#39;, &#39;Column2&#39;, &#39;Column3&#39;]]<\/p>\n<h2><strong>\u8f93\u51fa\u6240\u9009\u5217\u7684\u6570\u636e<\/strong><\/h2>\n<p>print(selected_columns)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165pandas\u5e93\uff0c\u7136\u540e\u4f7f\u7528<code>read_excel<\/code>\u51fd\u6570\u8bfb\u53d6Excel\u6587\u4ef6\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528\u5217\u540d\u9009\u62e9\u6240\u9700\u7684\u5217\u6570\u636e\uff0c\u5e76\u5c06\u5176\u5b58\u50a8\u5728<code>selected_columns<\/code>\u53d8\u91cf\u4e2d\u3002\u6700\u540e\uff0c\u6211\u4eec\u6253\u5370\u6240\u9009\u5217\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u4ecb\u7ecdpandas\u5e93\u7684\u4f7f\u7528<\/strong><\/p>\n<\/p>\n<p><p>pandas\u5e93\u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u6570\u636e\u5904\u7406\u5e93\u4e4b\u4e00\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6570\u636e\u5904\u7406\u529f\u80fd\uff0c\u5305\u62ec\u8bfb\u53d6\u548c\u5199\u5165Excel\u6587\u4ef6\u3001\u9009\u62e9\u548c\u8fc7\u6ee4\u6570\u636e\u3001\u6570\u636e\u6e05\u6d17\u548c\u8f6c\u6362\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684pandas\u51fd\u6570\u548c\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li><code>read_excel<\/code>\uff1a\u8bfb\u53d6Excel\u6587\u4ef6\u5e76\u8fd4\u56de\u4e00\u4e2aDataFrame\u5bf9\u8c61\u3002<\/li>\n<li><code>to_excel<\/code>\uff1a\u5c06DataFrame\u5bf9\u8c61\u5199\u5165Excel\u6587\u4ef6\u3002<\/li>\n<li><code>head<\/code>\uff1a\u8fd4\u56de\u524dn\u884c\u6570\u636e\uff0c\u9ed8\u8ba4\u8fd4\u56de\u524d5\u884c\u3002<\/li>\n<li><code>t<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>l<\/code>\uff1a\u8fd4\u56de\u540en\u884c\u6570\u636e\uff0c\u9ed8\u8ba4\u8fd4\u56de\u540e5\u884c\u3002<\/li>\n<li><code>info<\/code>\uff1a\u663e\u793aDataFrame\u7684\u57fa\u672c\u4fe1\u606f\uff0c\u5305\u62ec\u6570\u636e\u7c7b\u578b\u548c\u975e\u7a7a\u503c\u8ba1\u6570\u3002<\/li>\n<li><code>describe<\/code>\uff1a\u751f\u6210\u63cf\u8ff0\u6027\u7edf\u8ba1\u4fe1\u606f\uff0c\u5305\u62ec\u8ba1\u6570\u3001\u5747\u503c\u3001\u6807\u51c6\u5dee\u3001\u6700\u5c0f\u503c\u548c\u6700\u5927\u503c\u7b49\u3002<\/li>\n<li><code>drop<\/code>\uff1a\u5220\u9664\u6307\u5b9a\u7684\u884c\u6216\u5217\u3002<\/li>\n<li><code>loc<\/code>\uff1a\u6839\u636e\u6807\u7b7e\u9009\u62e9\u884c\u6216\u5217\u6570\u636e\u3002<\/li>\n<li><code>iloc<\/code>\uff1a\u6839\u636e\u4f4d\u7f6e\u9009\u62e9\u884c\u6216\u5217\u6570\u636e\u3002<\/li>\n<\/ol>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u51fd\u6570\u548c\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u8bfb\u53d6Excel\u6587\u4ef6<\/strong><\/h2>\n<p>df = pd.read_excel(&#39;example.xlsx&#39;)<\/p>\n<h2><strong>\u663e\u793a\u524d5\u884c\u6570\u636e<\/strong><\/h2>\n<p>print(df.head())<\/p>\n<h2><strong>\u663e\u793a\u540e5\u884c\u6570\u636e<\/strong><\/h2>\n<p>print(df.tail())<\/p>\n<h2><strong>\u663e\u793aDataFrame\u7684\u57fa\u672c\u4fe1\u606f<\/strong><\/h2>\n<p>print(df.info())<\/p>\n<h2><strong>\u751f\u6210\u63cf\u8ff0\u6027\u7edf\u8ba1\u4fe1\u606f<\/strong><\/h2>\n<p>print(df.describe())<\/p>\n<h2><strong>\u5220\u9664\u6307\u5b9a\u7684\u5217<\/strong><\/h2>\n<p>df = df.drop([&#39;Column4&#39;, &#39;Column5&#39;], axis=1)<\/p>\n<h2><strong>\u6839\u636e\u6807\u7b7e\u9009\u62e9\u884c\u6216\u5217\u6570\u636e<\/strong><\/h2>\n<p>selected_rows = df.loc[0:4, [&#39;Column1&#39;, &#39;Column2&#39;]]<\/p>\n<h2><strong>\u6839\u636e\u4f4d\u7f6e\u9009\u62e9\u884c\u6216\u5217\u6570\u636e<\/strong><\/h2>\n<p>selected_rows_by_position = df.iloc[0:4, 0:2]<\/p>\n<h2><strong>\u8f93\u51fa\u6240\u9009\u884c\u6216\u5217\u7684\u6570\u636e<\/strong><\/h2>\n<p>print(selected_rows)<\/p>\n<p>print(selected_rows_by_position)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165pandas\u5e93\uff0c\u7136\u540e\u4f7f\u7528<code>read_excel<\/code>\u51fd\u6570\u8bfb\u53d6Excel\u6587\u4ef6\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528<code>head<\/code>\u548c<code>tail<\/code>\u51fd\u6570\u663e\u793a\u524d5\u884c\u548c\u540e5\u884c\u6570\u636e\uff0c\u5e76\u4f7f\u7528<code>info<\/code>\u548c<code>describe<\/code>\u51fd\u6570\u663e\u793aDataFrame\u7684\u57fa\u672c\u4fe1\u606f\u548c\u63cf\u8ff0\u6027\u7edf\u8ba1\u4fe1\u606f\u3002\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528<code>drop<\/code>\u51fd\u6570\u5220\u9664\u6307\u5b9a\u7684\u5217\uff0c\u5e76\u4f7f\u7528<code>loc<\/code>\u548c<code>iloc<\/code>\u51fd\u6570\u6839\u636e\u6807\u7b7e\u548c\u4f4d\u7f6e\u9009\u62e9\u884c\u6216\u5217\u6570\u636e\u3002\u6700\u540e\uff0c\u6211\u4eec\u6253\u5370\u6240\u9009\u884c\u6216\u5217\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><p><strong>\u5904\u7406Excel\u6587\u4ef6\u4e2d\u7684\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u8bfb\u53d6\u548c\u9009\u62e9Excel\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u4e4b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528pandas\u5e93\u7684\u5404\u79cd\u51fd\u6570\u548c\u65b9\u6cd5\u5bf9\u6570\u636e\u8fdb\u884c\u5904\u7406\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u6570\u636e\u5904\u7406\u64cd\u4f5c\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u6570\u636e\u6e05\u6d17<\/strong>\uff1a\u5305\u62ec\u5904\u7406\u7f3a\u5931\u503c\u3001\u53bb\u9664\u91cd\u590d\u503c\u3001\u5904\u7406\u5f02\u5e38\u503c\u7b49\u3002<\/li>\n<li><strong>\u6570\u636e\u8f6c\u6362<\/strong>\uff1a\u5305\u62ec\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u3001\u6570\u636e\u683c\u5f0f\u8f6c\u6362\u3001\u5355\u4f4d\u8f6c\u6362\u7b49\u3002<\/li>\n<li><strong>\u6570\u636e\u805a\u5408<\/strong>\uff1a\u5305\u62ec\u5206\u7ec4\u805a\u5408\u3001\u6570\u636e\u900f\u89c6\u8868\u3001\u4ea4\u53c9\u8868\u7b49\u3002<\/li>\n<li><strong>\u6570\u636e\u5408\u5e76<\/strong>\uff1a\u5305\u62ec\u5408\u5e76\u3001\u8fde\u63a5\u3001\u62fc\u63a5\u7b49\u3002<\/li>\n<\/ol>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u6570\u636e\u5904\u7406\u64cd\u4f5c\u7684\u8be6\u7ec6\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u8bfb\u53d6Excel\u6587\u4ef6<\/strong><\/h2>\n<p>df = pd.read_excel(&#39;example.xlsx&#39;)<\/p>\n<h2><strong>\u6570\u636e\u6e05\u6d17\uff1a\u5904\u7406\u7f3a\u5931\u503c<\/strong><\/h2>\n<p>df = df.fillna(0)  # \u5c06\u7f3a\u5931\u503c\u66ff\u6362\u4e3a0<\/p>\n<h2><strong>\u6570\u636e\u6e05\u6d17\uff1a\u53bb\u9664\u91cd\u590d\u503c<\/strong><\/h2>\n<p>df = df.drop_duplicates()<\/p>\n<h2><strong>\u6570\u636e\u8f6c\u6362\uff1a\u6570\u636e\u7c7b\u578b\u8f6c\u6362<\/strong><\/h2>\n<p>df[&#39;Column1&#39;] = df[&#39;Column1&#39;].astype(int)<\/p>\n<h2><strong>\u6570\u636e\u8f6c\u6362\uff1a\u6570\u636e\u683c\u5f0f\u8f6c\u6362<\/strong><\/h2>\n<p>df[&#39;Date&#39;] = pd.to_datetime(df[&#39;Date&#39;], format=&#39;%Y-%m-%d&#39;)<\/p>\n<h2><strong>\u6570\u636e\u805a\u5408\uff1a\u5206\u7ec4\u805a\u5408<\/strong><\/h2>\n<p>grouped_df = df.groupby(&#39;Category&#39;).sum()<\/p>\n<h2><strong>\u6570\u636e\u805a\u5408\uff1a\u6570\u636e\u900f\u89c6\u8868<\/strong><\/h2>\n<p>pivot_table = pd.pivot_table(df, values=&#39;Value&#39;, index=&#39;Category&#39;, columns=&#39;Date&#39;, aggfunc=&#39;sum&#39;)<\/p>\n<h2><strong>\u6570\u636e\u5408\u5e76\uff1a\u5408\u5e76<\/strong><\/h2>\n<p>df1 = pd.read_excel(&#39;example1.xlsx&#39;)<\/p>\n<p>df2 = pd.read_excel(&#39;example2.xlsx&#39;)<\/p>\n<p>merged_df = pd.merge(df1, df2, on=&#39;ID&#39;)<\/p>\n<h2><strong>\u6570\u636e\u5408\u5e76\uff1a\u8fde\u63a5<\/strong><\/h2>\n<p>concatenated_df = pd.concat([df1, df2])<\/p>\n<h2><strong>\u8f93\u51fa\u5904\u7406\u540e\u7684\u6570\u636e<\/strong><\/h2>\n<p>print(df)<\/p>\n<p>print(grouped_df)<\/p>\n<p>print(pivot_table)<\/p>\n<p>print(merged_df)<\/p>\n<p>print(concatenated_df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165pandas\u5e93\uff0c\u7136\u540e\u4f7f\u7528<code>read_excel<\/code>\u51fd\u6570\u8bfb\u53d6Excel\u6587\u4ef6\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u8fdb\u884c\u4e86\u4ee5\u4e0b\u6570\u636e\u5904\u7406\u64cd\u4f5c\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u6570\u636e\u6e05\u6d17<\/strong>\uff1a\u4f7f\u7528<code>fillna<\/code>\u51fd\u6570\u5c06\u7f3a\u5931\u503c\u66ff\u6362\u4e3a0\uff0c\u4f7f\u7528<code>drop_duplicates<\/code>\u51fd\u6570\u53bb\u9664\u91cd\u590d\u503c\u3002<\/li>\n<li><strong>\u6570\u636e\u8f6c\u6362<\/strong>\uff1a\u4f7f\u7528<code>astype<\/code>\u51fd\u6570\u5c06\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u4e3a\u6574\u6570\uff0c\u4f7f\u7528<code>to_datetime<\/code>\u51fd\u6570\u5c06\u6570\u636e\u683c\u5f0f\u8f6c\u6362\u4e3a\u65e5\u671f\u3002<\/li>\n<li><strong>\u6570\u636e\u805a\u5408<\/strong>\uff1a\u4f7f\u7528<code>groupby<\/code>\u51fd\u6570\u5bf9\u6570\u636e\u8fdb\u884c\u5206\u7ec4\u805a\u5408\uff0c\u4f7f\u7528<code>pivot_table<\/code>\u51fd\u6570\u751f\u6210\u6570\u636e\u900f\u89c6\u8868\u3002<\/li>\n<li><strong>\u6570\u636e\u5408\u5e76<\/strong>\uff1a\u4f7f\u7528<code>merge<\/code>\u51fd\u6570\u5408\u5e76\u4e24\u4e2aDataFrame\u5bf9\u8c61\uff0c\u4f7f\u7528<code>concat<\/code>\u51fd\u6570\u8fde\u63a5\u4e24\u4e2aDataFrame\u5bf9\u8c61\u3002<\/li>\n<\/ol>\n<p><p>\u6700\u540e\uff0c\u6211\u4eec\u6253\u5370\u5904\u7406\u540e\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><p><strong>\u603b\u7ed3<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528Python\u4e2d\u7684pandas\u5e93\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u5730\u8bfb\u53d6\u3001\u9009\u62e9\u548c\u5904\u7406Excel\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528pandas\u5e93\u8bfb\u53d6Excel\u6587\u4ef6\u5e76\u9009\u62e9\u6240\u9700\u7684\u5217\u6570\u636e\uff0c\u5c55\u793a\u4e86\u4e00\u4e9b\u5e38\u7528\u7684pandas\u51fd\u6570\u548c\u65b9\u6cd5\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684\u6570\u636e\u5904\u7406\u64cd\u4f5c\u7684\u8be6\u7ec6\u793a\u4f8b\u3002\u5e0c\u671b\u8fd9\u4e9b\u5185\u5bb9\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u622a\u53d6Excel\u4e2d\u7684\u7279\u5b9a\u5217\uff1f<\/strong><br \/>\u53ef\u4ee5\u4f7f\u7528Pandas\u5e93\u6765\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88c5Pandas\u548copenpyxl\u5e93\u3002\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u8bfb\u53d6Excel\u6587\u4ef6\u5e76\u9009\u62e9\u7279\u5b9a\u5217\uff1a<\/p>\n<pre><code class=\"language-python\">import pandas as pd\n\n# \u8bfb\u53d6Excel\u6587\u4ef6\ndf = pd.read_excel(&#39;your_file.xlsx&#39;)\n\n# \u622a\u53d6\u7279\u5b9a\u5217\nselected_columns = df[[&#39;Column1&#39;, &#39;Column2&#39;]]  # \u66ff\u6362\u4e3a\u60a8\u9700\u8981\u7684\u5217\u540d\n<\/code><\/pre>\n<p>\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u65b9\u4fbf\u5730\u83b7\u53d6\u548c\u5904\u7406\u6240\u9700\u7684\u6570\u636e\u3002<\/p>\n<p><strong>Pandas\u5e93\u5728\u5904\u7406Excel\u6587\u4ef6\u65f6\u6709\u54ea\u4e9b\u4f18\u52bf\uff1f<\/strong><br \/>Pandas\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u529f\u80fd\uff0c\u80fd\u591f\u8f7b\u677e\u8bfb\u53d6\u3001\u5199\u5165\u548c\u64cd\u4f5cExcel\u6587\u4ef6\u3002\u5b83\u652f\u6301\u5bf9\u6570\u636e\u8fdb\u884c\u8fc7\u6ee4\u3001\u6392\u5e8f\u548c\u5206\u7ec4\u7b49\u64cd\u4f5c\uff0c\u6781\u5927\u5730\u63d0\u9ad8\u4e86\u6570\u636e\u5206\u6790\u7684\u6548\u7387\u3002\u6b64\u5916\uff0cPandas\u8fd8\u53ef\u4ee5\u4e0eNumPy\u65e0\u7f1d\u7ed3\u5408\uff0c\u4f7f\u590d\u6742\u7684\u6570\u636e\u8ba1\u7b97\u53d8\u5f97\u66f4\u52a0\u7b80\u5355\u3002<\/p>\n<p><strong>\u5982\u4f55\u4fdd\u5b58\u622a\u53d6\u540e\u7684\u6570\u636e\u5230\u65b0\u7684Excel\u6587\u4ef6\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u4f7f\u7528Pandas\u7684<code>to_excel()<\/code>\u65b9\u6cd5\u5c06\u622a\u53d6\u540e\u7684\u6570\u636e\u4fdd\u5b58\u5230\u65b0\u7684Excel\u6587\u4ef6\u4e2d\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-python\"># \u4fdd\u5b58\u622a\u53d6\u540e\u7684\u6570\u636e\u5230\u65b0\u7684Excel\u6587\u4ef6\nselected_columns.to_excel(&#39;output_file.xlsx&#39;, index=False)\n<\/code><\/pre>\n<p>\u8fd9\u6837\uff0c\u60a8\u5c31\u80fd\u5c06\u6240\u9700\u7684\u5217\u4fdd\u5b58\u4e3a\u4e00\u4e2a\u65b0\u7684Excel\u6587\u6863\uff0c\u65b9\u4fbf\u540e\u7eed\u7684\u4f7f\u7528\u6216\u5206\u4eab\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u5982\u4f55\u5728Excel\u4e2d\u622a\u53d6\u4e00\u6bb5\u5217 \u8981\u5728Python\u4e2d\u622a\u53d6Excel\u4e2d\u7684\u4e00\u6bb5\u5217\uff0c\u53ef\u4ee5\u4f7f\u7528pandas\u5e93\u3001 [&hellip;]","protected":false},"author":3,"featured_media":1084064,"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\/1084061"}],"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=1084061"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1084061\/revisions"}],"predecessor-version":[{"id":1084065,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1084061\/revisions\/1084065"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1084064"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1084061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1084061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1084061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}