{"id":1160866,"date":"2025-01-13T19:09:59","date_gmt":"2025-01-13T11:09:59","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1160866.html"},"modified":"2025-01-13T19:10:04","modified_gmt":"2025-01-13T11:10:04","slug":"%e4%b8%89%e5%88%97python%e5%a6%82%e4%bd%95%e7%94%9f%e6%88%90%e7%9f%a9%e9%98%b5-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1160866.html","title":{"rendered":"\u4e09\u5217python\u5982\u4f55\u751f\u6210\u77e9\u9635"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25202240\/0a08bc97-9297-42ef-a6d2-dc419eb68502.webp\" alt=\"\u4e09\u5217python\u5982\u4f55\u751f\u6210\u77e9\u9635\" \/><\/p>\n<p><p> \u5728Python\u4e2d\u751f\u6210\u77e9\u9635\u6709\u591a\u79cd\u65b9\u6cd5\uff0c<strong>\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u89e3\u6790\u3001Numpy\u5e93\u3001Pandas\u5e93<\/strong>\u3002\u5176\u4e2d\uff0c\u4f7f\u7528Numpy\u5e93\u662f\u6700\u5e38\u89c1\u548c\u6700\u65b9\u4fbf\u7684\u65b9\u6cd5\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u4e00\u79cd\u65b9\u6cd5\uff0c\u5373\u4f7f\u7528Numpy\u5e93\u751f\u6210\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u5217\u8868\u89e3\u6790\u751f\u6210\u77e9\u9635<\/h3>\n<\/p>\n<p><p>\u5217\u8868\u89e3\u6790\uff08List Comprehension\uff09\u662fPython\u7684\u4e00\u79cd\u7b80\u6d01\u800c\u5f3a\u5927\u7684\u751f\u6210\u5217\u8868\u7684\u65b9\u6cd5\u3002\u53ef\u4ee5\u5229\u7528\u5b83\u6765\u751f\u6210\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u4e00\u4e2a3x3\u7684\u77e9\u9635\uff0c\u5176\u4e2d\u5143\u7d20\u4e3a\u4ece1\u52309\u7684\u6570\u5b57<\/p>\n<p>matrix = [[j + i * 3 for j in range(1, 4)] for i in range(3)]<\/p>\n<p>print(matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u89e3\u91ca\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5916\u5c42\u5faa\u73af<code>for i in range(3)<\/code>\u751f\u6210\u4e09\u884c\u3002<\/li>\n<li>\u5185\u5c42\u5faa\u73af<code>for j in range(1, 4)<\/code>\u751f\u6210\u6bcf\u884c\u4e2d\u7684\u4e09\u4e2a\u5143\u7d20\u3002<\/li>\n<\/ul>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u9002\u5408\u751f\u6210\u7b80\u5355\u7684\u77e9\u9635\uff0c\u4f46\u64cd\u4f5c\u590d\u6742\u77e9\u9635\u65f6\u4f1a\u6bd4\u8f83\u7e41\u7410\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528Numpy\u5e93\u751f\u6210\u77e9\u9635<\/h3>\n<\/p>\n<p><p>Numpy\u662fPython\u4e2d\u4e00\u4e2a\u5f3a\u5927\u7684\u79d1\u5b66\u8ba1\u7b97\u5e93\uff0c\u4e13\u95e8\u7528\u6765\u5904\u7406\u591a\u7ef4\u6570\u7ec4\u548c\u77e9\u9635\u3002\u4f7f\u7528Numpy\u751f\u6210\u77e9\u9635\u65e2\u7b80\u5355\u53c8\u9ad8\u6548\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5Numpy\u5e93<\/h4>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Numpy\u5e93\u4e4b\u524d\u9700\u8981\u5b89\u88c5\u5b83\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u521b\u5efa\u77e9\u9635<\/h4>\n<\/p>\n<p><p>Numpy\u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u521b\u5efa\u77e9\u9635\uff0c\u5982\u4f7f\u7528\u6570\u7ec4\u3001\u968f\u673a\u6570\u3001\u5168\u96f6\u77e9\u9635\u3001\u5168\u4e00\u77e9\u9635\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a3x3\u7684\u77e9\u9635\uff0c\u5176\u4e2d\u5143\u7d20\u4e3a\u4ece1\u52309\u7684\u6570\u5b57<\/strong><\/h2>\n<p>matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])<\/p>\n<p>print(matrix)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a3x3\u7684\u5168\u96f6\u77e9\u9635<\/strong><\/h2>\n<p>zero_matrix = np.zeros((3, 3))<\/p>\n<p>print(zero_matrix)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a3x3\u7684\u5168\u4e00\u77e9\u9635<\/strong><\/h2>\n<p>one_matrix = np.ones((3, 3))<\/p>\n<p>print(one_matrix)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a3x3\u7684\u968f\u673a\u77e9\u9635<\/strong><\/h2>\n<p>random_matrix = np.random.rand(3, 3)<\/p>\n<p>print(random_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u89e3\u91ca\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li><code>np.array<\/code>\u53ef\u4ee5\u76f4\u63a5\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u77e9\u9635\u3002<\/li>\n<li><code>np.zeros<\/code>\u521b\u5efa\u5168\u96f6\u77e9\u9635\u3002<\/li>\n<li><code>np.ones<\/code>\u521b\u5efa\u5168\u4e00\u77e9\u9635\u3002<\/li>\n<li><code>np.random.rand<\/code>\u521b\u5efa\u968f\u673a\u77e9\u9635\u3002<\/li>\n<\/ul>\n<p><p>\u4f7f\u7528Numpy\u4e0d\u4ec5\u53ef\u4ee5\u65b9\u4fbf\u5730\u751f\u6210\u77e9\u9635\uff0c\u8fd8\u53ef\u4ee5\u8fdb\u884c\u590d\u6742\u7684\u77e9\u9635\u8fd0\u7b97\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528Pandas\u5e93\u751f\u6210\u77e9\u9635<\/h3>\n<\/p>\n<p><p>Pandas\u662f\u53e6\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u5e93\uff0c\u4e3b\u8981\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u6570\u636e\u64cd\u4f5c\u3002\u867d\u7136Pandas\u4e3b\u8981\u7528\u4e8e\u5904\u7406\u6570\u636e\u6846\uff08DataFrame\uff09\uff0c\u4f46\u4e5f\u53ef\u4ee5\u7528\u6765\u751f\u6210\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5Pandas\u5e93<\/h4>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Pandas\u5e93\u4e4b\u524d\u9700\u8981\u5b89\u88c5\u5b83\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u521b\u5efa\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528Pandas\u5e93\u751f\u6210\u77e9\u9635\u901a\u5e38\u662f\u901a\u8fc7\u521b\u5efa\u6570\u636e\u6846\uff0c\u7136\u540e\u5c06\u5176\u8f6c\u6362\u4e3a\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a3x3\u7684\u6570\u636e\u6846<\/strong><\/h2>\n<p>df = pd.DataFrame({<\/p>\n<p>    &#39;A&#39;: [1, 4, 7],<\/p>\n<p>    &#39;B&#39;: [2, 5, 8],<\/p>\n<p>    &#39;C&#39;: [3, 6, 9]<\/p>\n<p>})<\/p>\n<h2><strong>\u5c06\u6570\u636e\u6846\u8f6c\u6362\u4e3a\u77e9\u9635<\/strong><\/h2>\n<p>matrix = df.values<\/p>\n<p>print(matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u89e3\u91ca\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li><code>pd.DataFrame<\/code>\u53ef\u4ee5\u521b\u5efa\u6570\u636e\u6846\u3002<\/li>\n<li><code>df.values<\/code>\u53ef\u4ee5\u5c06\u6570\u636e\u6846\u8f6c\u6362\u4e3aNumpy\u6570\u7ec4\uff0c\u5373\u77e9\u9635\u3002<\/li>\n<\/ul>\n<p><p>Pandas\u9002\u5408\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u5904\u7406\uff0c\u4f46\u5728\u751f\u6210\u77e9\u9635\u65f6\u4e0d\u5982Numpy\u65b9\u4fbf\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u77e9\u9635\u7684\u57fa\u672c\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u751f\u6210\u77e9\u9635\u540e\uff0c\u53ef\u4ee5\u5bf9\u77e9\u9635\u8fdb\u884c\u5404\u79cd\u64cd\u4f5c\uff0c\u5982\u77e9\u9635\u52a0\u6cd5\u3001\u51cf\u6cd5\u3001\u4e58\u6cd5\u3001\u8f6c\u7f6e\u7b49\u3002\u4e0b\u9762\u4ee5Numpy\u5e93\u4e3a\u4f8b\uff0c\u4ecb\u7ecd\u4e00\u4e9b\u57fa\u672c\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h4>1. \u77e9\u9635\u52a0\u6cd5\u548c\u51cf\u6cd5<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e24\u4e2a3x3\u7684\u77e9\u9635<\/strong><\/h2>\n<p>matrix1 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])<\/p>\n<p>matrix2 = np.array([[9, 8, 7], [6, 5, 4], [3, 2, 1]])<\/p>\n<h2><strong>\u77e9\u9635\u52a0\u6cd5<\/strong><\/h2>\n<p>matrix_add = matrix1 + matrix2<\/p>\n<p>print(matrix_add)<\/p>\n<h2><strong>\u77e9\u9635\u51cf\u6cd5<\/strong><\/h2>\n<p>matrix_sub = matrix1 - matrix2<\/p>\n<p>print(matrix_sub)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u89e3\u91ca\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528<code>+<\/code>\u53ef\u4ee5\u8fdb\u884c\u77e9\u9635\u52a0\u6cd5\u3002<\/li>\n<li>\u4f7f\u7528<code>-<\/code>\u53ef\u4ee5\u8fdb\u884c\u77e9\u9635\u51cf\u6cd5\u3002<\/li>\n<\/ul>\n<p><h4>2. \u77e9\u9635\u4e58\u6cd5<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e24\u4e2a3x3\u7684\u77e9\u9635<\/strong><\/h2>\n<p>matrix1 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])<\/p>\n<p>matrix2 = np.array([[9, 8, 7], [6, 5, 4], [3, 2, 1]])<\/p>\n<h2><strong>\u77e9\u9635\u4e58\u6cd5<\/strong><\/h2>\n<p>matrix_mul = np.dot(matrix1, matrix2)<\/p>\n<p>print(matrix_mul)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u89e3\u91ca\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528<code>np.dot<\/code>\u53ef\u4ee5\u8fdb\u884c\u77e9\u9635\u4e58\u6cd5\u3002<\/li>\n<\/ul>\n<p><h4>3. \u77e9\u9635\u8f6c\u7f6e<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a3x3\u7684\u77e9\u9635<\/strong><\/h2>\n<p>matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])<\/p>\n<h2><strong>\u77e9\u9635\u8f6c\u7f6e<\/strong><\/h2>\n<p>matrix_transpose = np.transpose(matrix)<\/p>\n<p>print(matrix_transpose)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u89e3\u91ca\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528<code>np.transpose<\/code>\u53ef\u4ee5\u5bf9\u77e9\u9635\u8fdb\u884c\u8f6c\u7f6e\u3002<\/li>\n<\/ul>\n<p><h3>\u4e94\u3001\u77e9\u9635\u7684\u9ad8\u7ea7\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u57fa\u672c\u64cd\u4f5c\uff0cNumpy\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u9ad8\u7ea7\u64cd\u4f5c\uff0c\u5982\u77e9\u9635\u6c42\u9006\u3001\u7279\u5f81\u503c\u548c\u7279\u5f81\u5411\u91cf\u3001\u5947\u5f02\u503c\u5206\u89e3\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1. \u77e9\u9635\u6c42\u9006<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a2x2\u7684\u77e9\u9635<\/strong><\/h2>\n<p>matrix = np.array([[1, 2], [3, 4]])<\/p>\n<h2><strong>\u77e9\u9635\u6c42\u9006<\/strong><\/h2>\n<p>matrix_inverse = np.linalg.inv(matrix)<\/p>\n<p>print(matrix_inverse)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u89e3\u91ca\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528<code>np.linalg.inv<\/code>\u53ef\u4ee5\u5bf9\u77e9\u9635\u8fdb\u884c\u6c42\u9006\u3002<\/li>\n<\/ul>\n<p><h4>2. \u77e9\u9635\u7684\u7279\u5f81\u503c\u548c\u7279\u5f81\u5411\u91cf<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a2x2\u7684\u77e9\u9635<\/strong><\/h2>\n<p>matrix = np.array([[1, 2], [3, 4]])<\/p>\n<h2><strong>\u77e9\u9635\u7684\u7279\u5f81\u503c\u548c\u7279\u5f81\u5411\u91cf<\/strong><\/h2>\n<p>eigenvalues, eigenvectors = np.linalg.eig(matrix)<\/p>\n<p>print(&quot;\u7279\u5f81\u503c:&quot;, eigenvalues)<\/p>\n<p>print(&quot;\u7279\u5f81\u5411\u91cf:&quot;, eigenvectors)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u89e3\u91ca\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528<code>np.linalg.eig<\/code>\u53ef\u4ee5\u6c42\u89e3\u77e9\u9635\u7684\u7279\u5f81\u503c\u548c\u7279\u5f81\u5411\u91cf\u3002<\/li>\n<\/ul>\n<p><h4>3. \u77e9\u9635\u7684\u5947\u5f02\u503c\u5206\u89e3<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a2x2\u7684\u77e9\u9635<\/strong><\/h2>\n<p>matrix = np.array([[1, 2], [3, 4]])<\/p>\n<h2><strong>\u77e9\u9635\u7684\u5947\u5f02\u503c\u5206\u89e3<\/strong><\/h2>\n<p>U, S, V = np.linalg.svd(matrix)<\/p>\n<p>print(&quot;U\u77e9\u9635:&quot;, U)<\/p>\n<p>print(&quot;\u5947\u5f02\u503c:&quot;, S)<\/p>\n<p>print(&quot;V\u77e9\u9635:&quot;, V)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u89e3\u91ca\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528<code>np.linalg.svd<\/code>\u53ef\u4ee5\u5bf9\u77e9\u9635\u8fdb\u884c\u5947\u5f02\u503c\u5206\u89e3\u3002<\/li>\n<\/ul>\n<p><h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\u751f\u6210\u77e9\u9635\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff0c\u6700\u5e38\u7528\u7684\u662fNumpy\u5e93\u3002<strong>\u5217\u8868\u89e3\u6790\u9002\u5408\u751f\u6210\u7b80\u5355\u7684\u77e9\u9635\uff0cNumpy\u5e93\u9002\u5408\u751f\u6210\u548c\u64cd\u4f5c\u590d\u6742\u7684\u77e9\u9635\uff0cPandas\u5e93\u9002\u5408\u6570\u636e\u5206\u6790\u548c\u5904\u7406<\/strong>\u3002\u5728\u77e9\u9635\u7684\u57fa\u672c\u64cd\u4f5c\u65b9\u9762\uff0cNumpy\u5e93\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u51fd\u6570\uff0c\u5982\u77e9\u9635\u52a0\u6cd5\u3001\u51cf\u6cd5\u3001\u4e58\u6cd5\u3001\u8f6c\u7f6e\u7b49\u3002\u5728\u77e9\u9635\u7684\u9ad8\u7ea7\u64cd\u4f5c\u65b9\u9762\uff0cNumpy\u5e93\u540c\u6837\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u529f\u80fd\uff0c\u5982\u77e9\u9635\u6c42\u9006\u3001\u7279\u5f81\u503c\u548c\u7279\u5f81\u5411\u91cf\u3001\u5947\u5f02\u503c\u5206\u89e3\u7b49\u3002\u638c\u63e1\u8fd9\u4e9b\u65b9\u6cd5\u548c\u64cd\u4f5c\uff0c\u53ef\u4ee5\u6781\u5927\u5730\u63d0\u9ad8\u6570\u636e\u5904\u7406\u548c\u79d1\u5b66\u8ba1\u7b97\u7684\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u751f\u6210\u4e00\u4e2a\u7279\u5b9a\u5927\u5c0f\u7684\u77e9\u9635\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u4e2d\u7684<code>numpy.zeros()<\/code>\u3001<code>numpy.ones()<\/code>\u6216<code>numpy.random.rand()<\/code>\u7b49\u51fd\u6570\u6765\u751f\u6210\u7279\u5b9a\u5927\u5c0f\u7684\u77e9\u9635\u3002\u4f8b\u5982\uff0c<code>numpy.zeros((3, 3))<\/code>\u5c06\u751f\u6210\u4e00\u4e2a3&#215;3\u7684\u96f6\u77e9\u9635\uff0c\u800c<code>numpy.random.rand(3, 3)<\/code>\u5c06\u751f\u6210\u4e00\u4e2a3&#215;3\u7684\u968f\u673a\u77e9\u9635\u3002\u786e\u4fdd\u5728\u4f7f\u7528\u8fd9\u4e9b\u529f\u80fd\u4e4b\u524d\u5df2\u5b89\u88c5NumPy\u5e93\uff0c\u5e76\u901a\u8fc7<code>import numpy as np<\/code>\u5bfc\u5165\u5b83\u3002<\/p>\n<p><strong>\u662f\u5426\u53ef\u4ee5\u4f7f\u7528Python\u751f\u6210\u5305\u542b\u7279\u5b9a\u503c\u7684\u77e9\u9635\uff1f<\/strong><br \/>\u5f53\u7136\u53ef\u4ee5\uff01\u60a8\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u4e2d\u7684<code>numpy.full()<\/code>\u51fd\u6570\u6765\u751f\u6210\u4e00\u4e2a\u5305\u542b\u7279\u5b9a\u503c\u7684\u77e9\u9635\u3002\u4f8b\u5982\uff0c<code>numpy.full((3, 3), 7)<\/code>\u5c06\u521b\u5efa\u4e00\u4e2a3&#215;3\u7684\u77e9\u9635\uff0c\u6240\u6709\u5143\u7d20\u90fd\u4e3a7\u3002\u6b64\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7\u5217\u8868\u63a8\u5bfc\u5f0f\u6216\u8005\u5d4c\u5957\u5faa\u73af\u624b\u52a8\u6784\u9020\u8fd9\u6837\u7684\u77e9\u9635\u3002<\/p>\n<p><strong>\u5982\u4f55\u4ece\u73b0\u6709\u6570\u636e\u521b\u5efa\u4e00\u4e2a\u77e9\u9635\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u4f7f\u7528NumPy\u7684<code>numpy.array()<\/code>\u65b9\u6cd5\u4ece\u73b0\u6709\u6570\u636e\uff08\u5982\u5217\u8868\u6216\u5143\u7ec4\uff09\u521b\u5efa\u77e9\u9635\u3002\u4f8b\u5982\uff0c<code>numpy.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])<\/code>\u5c06\u751f\u6210\u4e00\u4e2a3&#215;3\u7684\u77e9\u9635\u3002\u786e\u4fdd\u8f93\u5165\u7684\u6570\u636e\u7ed3\u6784\u662f\u89c4\u5219\u7684\uff0c\u5373\u6bcf\u4e00\u884c\u7684\u957f\u5ea6\u76f8\u540c\uff0c\u8fd9\u6837\u624d\u80fd\u6210\u529f\u521b\u5efa\u77e9\u9635\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u751f\u6210\u77e9\u9635\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u89e3\u6790\u3001Numpy\u5e93\u3001Pandas\u5e93\u3002\u5176\u4e2d\uff0c\u4f7f\u7528Numpy\u5e93\u662f\u6700 [&hellip;]","protected":false},"author":3,"featured_media":1160876,"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\/1160866"}],"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=1160866"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1160866\/revisions"}],"predecessor-version":[{"id":1160879,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1160866\/revisions\/1160879"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1160876"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1160866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1160866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1160866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}