{"id":1116530,"date":"2025-01-08T18:17:20","date_gmt":"2025-01-08T10:17:20","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1116530.html"},"modified":"2025-01-08T18:17:23","modified_gmt":"2025-01-08T10:17:23","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e5%b0%86%e6%95%b0%e7%bb%84%e5%8f%98%e6%88%90%e7%9f%a9%e9%98%b5%e7%9a%84%e5%bd%a2%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1116530.html","title":{"rendered":"\u5982\u4f55\u7528python\u5c06\u6570\u7ec4\u53d8\u6210\u77e9\u9635\u7684\u5f62\u5f0f"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25080832\/8a56b11c-b992-4de1-958a-b72d9dc14ec0.webp\" alt=\"\u5982\u4f55\u7528python\u5c06\u6570\u7ec4\u53d8\u6210\u77e9\u9635\u7684\u5f62\u5f0f\" \/><\/p>\n<p><p> <strong>\u7528Python\u5c06\u6570\u7ec4\u53d8\u6210\u77e9\u9635\u7684\u5f62\u5f0f\u7684\u65b9\u6cd5\u6709\uff1a\u4f7f\u7528Numpy\u5e93\u3001\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u3001\u4f7f\u7528Pandas\u5e93\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u5176\u4e2d\uff0c<strong>\u4f7f\u7528Numpy\u5e93<\/strong>\u662f\u6700\u5e38\u89c1\u4e14\u9ad8\u6548\u7684\u65b9\u6cd5\u3002Numpy\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u503c\u8ba1\u7b97\u5e93\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u7528\u4e8e\u6570\u7ec4\u548c\u77e9\u9635\u64cd\u4f5c\u7684\u51fd\u6570\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Numpy\u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001Numpy\u5e93<\/h3>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5Numpy\u5e93<\/h4>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Numpy\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5\u8be5\u5e93\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code>pip install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u5bfc\u5165Numpy\u5e93<\/h4>\n<\/p>\n<p><p>\u5728Python\u811a\u672c\u4e2d\u5bfc\u5165Numpy\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u5047\u8bbe\u6709\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Numpy\u7684<code>reshape<\/code>\u51fd\u6570\u5c06\u5176\u8f6c\u6362\u4e3a\u77e9\u9635\u3002\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u4e00\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>array = [1, 2, 3, 4, 5, 6]<\/p>\n<h2><strong>\u8f6c\u6362\u4e3a2\u884c3\u5217\u7684\u77e9\u9635<\/strong><\/h2>\n<p>matrix = np.reshape(array, (2, 3))<\/p>\n<p>print(matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<\/p>\n<p><pre><code>[[1 2 3]<\/p>\n<p> [4 5 6]]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>np.reshape<\/code>\u51fd\u6570\u5c06\u6570\u7ec4<code>array<\/code>\u8f6c\u6362\u4e3a\u4e00\u4e2a2\u884c3\u5217\u7684\u77e9\u9635\u3002<code>reshape<\/code>\u51fd\u6570\u7684\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u4e00\u4e2a\u5143\u7ec4\uff0c\u8868\u793a\u77e9\u9635\u7684\u5f62\u72b6\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u6ce8\u610f\u4e8b\u9879<\/h4>\n<\/p>\n<ul>\n<li><strong>\u6570\u7ec4\u5143\u7d20\u6570\u91cf\u4e0e\u77e9\u9635\u5f62\u72b6\u8981\u5339\u914d<\/strong>\uff1a\u5982\u679c\u6570\u7ec4\u7684\u5143\u7d20\u6570\u91cf\u4e0e\u6307\u5b9a\u7684\u77e9\u9635\u5f62\u72b6\u4e0d\u5339\u914d\uff0c<code>reshape<\/code>\u51fd\u6570\u5c06\u4f1a\u629b\u51fa\u9519\u8bef\u3002<\/li>\n<li><strong>\u591a\u7ef4\u6570\u7ec4<\/strong>\uff1a<code>reshape<\/code>\u51fd\u6570\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5c06\u591a\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a\u6307\u5b9a\u5f62\u72b6\u7684\u77e9\u9635\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5c06\u4e00\u4e2a\u4e09\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a\u4e8c\u7ef4\u77e9\u9635\u3002<\/li>\n<\/ul>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u4e09\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>array_3d = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])<\/p>\n<h2><strong>\u8f6c\u6362\u4e3a\u4e8c\u7ef4\u77e9\u9635<\/strong><\/h2>\n<p>matrix_2d = np.reshape(array_3d, (4, 2))<\/p>\n<p>print(matrix_2d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<\/p>\n<p><pre><code>[[1 2]<\/p>\n<p> [3 4]<\/p>\n<p> [5 6]<\/p>\n<p> [7 8]]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u4e00\u4e2a\u4e09\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a\u4e00\u4e2a4\u884c2\u5217\u7684\u4e8c\u7ef4\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5217\u8868\u63a8\u5bfc\u5f0f<\/h3>\n<\/p>\n<p><p>\u9664\u4e86Numpy\u5e93\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528Python\u7684\u5217\u8868\u63a8\u5bfc\u5f0f\u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a\u77e9\u9635\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u8f83\u7b80\u5355\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u793a\u4f8b<\/h4>\n<\/p>\n<p><p>\u5047\u8bbe\u6709\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u5c06\u5176\u8f6c\u6362\u4e3a\u77e9\u9635\u3002\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4e00\u7ef4\u6570\u7ec4<\/p>\n<p>array = [1, 2, 3, 4, 5, 6]<\/p>\n<h2><strong>\u8f6c\u6362\u4e3a2\u884c3\u5217\u7684\u77e9\u9635<\/strong><\/h2>\n<p>rows, cols = 2, 3<\/p>\n<p>matrix = [array[i * cols:(i + 1) * cols] for i in range(rows)]<\/p>\n<p>print(matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<\/p>\n<p><pre><code>[[1, 2, 3], [4, 5, 6]]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u5c06\u6570\u7ec4<code>array<\/code>\u8f6c\u6362\u4e3a\u4e00\u4e2a2\u884c3\u5217\u7684\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u591a\u7ef4\u6570\u7ec4<\/h4>\n<\/p>\n<p><p>\u540c\u6837\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u5904\u7406\u591a\u7ef4\u6570\u7ec4\u3002\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4e8c\u7ef4\u6570\u7ec4<\/p>\n<p>array_2d = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]<\/p>\n<h2><strong>\u8f6c\u6362\u4e3a3\u884c3\u5217\u7684\u77e9\u9635<\/strong><\/h2>\n<p>rows, cols = 3, 3<\/p>\n<p>matrix = [[array_2d[i][j] for j in range(cols)] for i in range(rows)]<\/p>\n<p>print(matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<\/p>\n<p><pre><code>[[1, 2, 3], [4, 5, 6], [7, 8, 9]]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u5c06\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001Pandas\u5e93<\/h3>\n<\/p>\n<p><p>Pandas\u662f\u4e00\u4e2a\u6570\u636e\u5206\u6790\u5e93\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u7528\u4e8e\u6570\u636e\u64cd\u4f5c\u548c\u5206\u6790\u7684\u51fd\u6570\u3002\u867d\u7136Pandas\u4e3b\u8981\u7528\u4e8e\u5904\u7406\u6570\u636e\u8868\u683c\uff0c\u4f46\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5Pandas\u5e93<\/h4>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Pandas\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5\u8be5\u5e93\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code>pip install pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u5bfc\u5165Pandas\u5e93<\/h4>\n<\/p>\n<p><p>\u5728Python\u811a\u672c\u4e2d\u5bfc\u5165Pandas\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u5047\u8bbe\u6709\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Pandas\u7684<code>DataFrame<\/code>\u51fd\u6570\u5c06\u5176\u8f6c\u6362\u4e3a\u77e9\u9635\u3002\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u4e00\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>array = [1, 2, 3, 4, 5, 6]<\/p>\n<h2><strong>\u8f6c\u6362\u4e3a2\u884c3\u5217\u7684\u77e9\u9635<\/strong><\/h2>\n<p>rows, cols = 2, 3<\/p>\n<p>matrix = pd.DataFrame(np.reshape(array, (rows, cols)))<\/p>\n<p>print(matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<\/p>\n<p><pre><code>   0  1  2<\/p>\n<p>0  1  2  3<\/p>\n<p>1  4  5  6<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528Pandas\u7684<code>DataFrame<\/code>\u51fd\u6570\u5c06\u6570\u7ec4<code>array<\/code>\u8f6c\u6362\u4e3a\u4e00\u4e2a2\u884c3\u5217\u7684\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u6ce8\u610f\u4e8b\u9879<\/h4>\n<\/p>\n<ul>\n<li><strong>Pandas\u7684DataFrame<\/strong>\uff1aPandas\u7684<code>DataFrame<\/code>\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u7c7b\u4f3c\u4e8e\u7535\u5b50\u8868\u683c\u3002<code>DataFrame<\/code>\u63d0\u4f9b\u4e86\u8bb8\u591a\u7528\u4e8e\u6570\u636e\u64cd\u4f5c\u548c\u5206\u6790\u7684\u51fd\u6570\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5904\u7406\u6570\u636e\u3002<\/li>\n<li><strong>\u4e0eNumpy\u7ed3\u5408\u4f7f\u7528<\/strong>\uff1aPandas\u901a\u5e38\u4e0eNumpy\u7ed3\u5408\u4f7f\u7528\uff0c\u53ef\u4ee5\u5145\u5206\u5229\u7528\u4e24\u8005\u7684\u4f18\u52bf\u3002<\/li>\n<\/ul>\n<p><h3>\u56db\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a\u77e9\u9635\u5728\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u4e2d\u975e\u5e38\u5e38\u89c1\uff0cPython\u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u3002<strong>Numpy\u5e93<\/strong>\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\uff0c\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u6570\u7ec4\u548c\u77e9\u9635\u64cd\u4f5c\u51fd\u6570\u3002<strong>\u5217\u8868\u63a8\u5bfc\u5f0f<\/strong>\u9002\u7528\u4e8e\u8f83\u7b80\u5355\u7684\u60c5\u51b5\uff0c\u53ef\u4ee5\u5feb\u901f\u5b9e\u73b0\u6570\u7ec4\u5230\u77e9\u9635\u7684\u8f6c\u6362\u3002<strong>Pandas\u5e93<\/strong>\u5219\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6570\u636e\u8868\u683c\u5904\u7406\u529f\u80fd\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5904\u7406\u548c\u5206\u6790\u6570\u636e\u3002<\/p>\n<\/p>\n<p><p>\u65e0\u8bba\u4f7f\u7528\u54ea\u79cd\u65b9\u6cd5\uff0c\u90fd\u9700\u8981\u786e\u4fdd\u6570\u7ec4\u7684\u5143\u7d20\u6570\u91cf\u4e0e\u77e9\u9635\u7684\u5f62\u72b6\u5339\u914d\u3002\u5982\u679c\u6570\u7ec4\u7684\u5143\u7d20\u6570\u91cf\u4e0e\u77e9\u9635\u7684\u5f62\u72b6\u4e0d\u5339\u914d\uff0c\u5c06\u4f1a\u5f15\u53d1\u9519\u8bef\u3002\u56e0\u6b64\uff0c\u5728\u8fdb\u884c\u6570\u7ec4\u5230\u77e9\u9635\u7684\u8f6c\u6362\u65f6\uff0c\u9700\u8981\u4ed4\u7ec6\u68c0\u67e5\u6570\u7ec4\u7684\u5927\u5c0f\u548c\u77e9\u9635\u7684\u5f62\u72b6\u3002<\/p>\n<\/p>\n<p><p>\u5e0c\u671b\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u60a8\u80fd\u591f\u638c\u63e1\u5982\u4f55\u4f7f\u7528Python\u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a\u77e9\u9635\uff0c\u5e76\u5728\u5b9e\u9645\u7684\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u4e2d\u7075\u6d3b\u5e94\u7528\u8fd9\u4e9b\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u5c06\u4e00\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a\u4e8c\u7ef4\u77e9\u9635\uff1f<\/strong><br \/>\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u4e2d\u7684<code>reshape<\/code>\u51fd\u6570\u6765\u5b9e\u73b0\u8fd9\u4e00\u8f6c\u6362\u3002\u9996\u5148\uff0c\u786e\u4fdd\u5df2\u5b89\u88c5NumPy\u5e93\u3002\u7136\u540e\uff0c\u4f60\u53ef\u4ee5\u5b9a\u4e49\u4e00\u7ef4\u6570\u7ec4\uff0c\u5e76\u8c03\u7528<code>reshape<\/code>\u65b9\u6cd5\uff0c\u5c06\u5176\u8f6c\u6362\u4e3a\u6240\u9700\u5f62\u72b6\u7684\u4e8c\u7ef4\u77e9\u9635\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">import numpy as np\n\narray = np.array([1, 2, 3, 4, 5, 6])\nmatrix = array.reshape(2, 3)  # \u8f6c\u6362\u4e3a2\u884c3\u5217\u7684\u77e9\u9635\nprint(matrix)\n<\/code><\/pre>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u5c06\u8f93\u51fa\u4e00\u4e2a2&#215;3\u7684\u77e9\u9635\u3002<\/p>\n<p><strong>\u5982\u679c\u6211\u7684\u6570\u7ec4\u5143\u7d20\u6570\u91cf\u4e0d\u9002\u5408\u76ee\u6807\u77e9\u9635\u7684\u5f62\u72b6\uff0c\u8be5\u5982\u4f55\u5904\u7406\uff1f<\/strong><br \/>\u5728\u4f7f\u7528<code>reshape<\/code>\u65b9\u6cd5\u65f6\uff0c\u6570\u7ec4\u7684\u5143\u7d20\u6570\u91cf\u5fc5\u987b\u4e0e\u76ee\u6807\u77e9\u9635\u7684\u5f62\u72b6\u76f8\u5339\u914d\u3002\u5982\u679c\u4e0d\u5339\u914d\uff0c\u4f1a\u629b\u51fa\u4e00\u4e2a\u9519\u8bef\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u5148\u8c03\u6574\u6570\u7ec4\u7684\u5143\u7d20\u6570\u91cf\uff0c\u6216\u8005\u9009\u62e9\u9002\u5408\u7684\u77e9\u9635\u5f62\u72b6\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u6709\u4e00\u4e2a\u5305\u542b8\u4e2a\u5143\u7d20\u7684\u6570\u7ec4\uff0c\u53ef\u4ee5\u5c06\u5176\u8f6c\u6362\u4e3a4&#215;2\u62162&#215;4\u7684\u77e9\u9635\uff0c\u4f46\u4e0d\u80fd\u8f6c\u6362\u4e3a3&#215;3\u7684\u77e9\u9635\u3002<\/p>\n<p><strong>\u9664\u4e86NumPy\uff0c\u8fd8\u6709\u5176\u4ed6\u5e93\u53ef\u4ee5\u7528\u6765\u8f6c\u6362\u6570\u7ec4\u4e3a\u77e9\u9635\u5417\uff1f<\/strong><br \/>\u9664\u4e86NumPy\uff0cPython\u7684\u5176\u4ed6\u5e93\u5982Pandas\u4e5f\u80fd\u591f\u5b9e\u73b0\u7c7b\u4f3c\u7684\u529f\u80fd\u3002Pandas\u4e2d\u7684<code>DataFrame<\/code>\u53ef\u4ee5\u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a\u8868\u683c\u5f62\u5f0f\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a  <\/p>\n<pre><code class=\"language-python\">import pandas as pd\n\narray = [1, 2, 3, 4, 5, 6]\ndf = pd.DataFrame(np.array(array).reshape(2, 3))  # \u8f6c\u6362\u4e3aDataFrame\u5f62\u5f0f\nprint(df)\n<\/code><\/pre>\n<p>\u8fd9\u5c06\u751f\u6210\u4e00\u4e2a\u5305\u542b\u6570\u636e\u7684\u8868\u683c\uff0c\u4fbf\u4e8e\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u7528Python\u5c06\u6570\u7ec4\u53d8\u6210\u77e9\u9635\u7684\u5f62\u5f0f\u7684\u65b9\u6cd5\u6709\uff1a\u4f7f\u7528Numpy\u5e93\u3001\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u3001\u4f7f\u7528Pandas\u5e93\u3002 \u5176\u4e2d\uff0c\u4f7f\u7528 [&hellip;]","protected":false},"author":3,"featured_media":1116537,"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\/1116530"}],"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=1116530"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1116530\/revisions"}],"predecessor-version":[{"id":1116539,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1116530\/revisions\/1116539"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1116537"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1116530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1116530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1116530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}