{"id":922038,"date":"2024-12-26T14:24:41","date_gmt":"2024-12-26T06:24:41","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/922038.html"},"modified":"2024-12-26T14:24:43","modified_gmt":"2024-12-26T06:24:43","slug":"python-%e7%9f%a9%e9%98%b5%e5%a6%82%e4%bd%95%e5%ae%9a%e4%b9%89","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/922038.html","title":{"rendered":"python \u77e9\u9635\u5982\u4f55\u5b9a\u4e49"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24210727\/68fda6e0-11fa-4336-9f7c-5948626c3030.webp\" alt=\"python \u77e9\u9635\u5982\u4f55\u5b9a\u4e49\" \/><\/p>\n<p><p> \u5728Python\u4e2d\u5b9a\u4e49\u77e9\u9635\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u6700\u5e38\u7528\u7684\u5305\u62ec<strong>\u4f7f\u7528\u5217\u8868\u5d4c\u5957\u3001\u5229\u7528NumPy\u5e93\u3001\u8fd0\u7528Pandas\u5e93<\/strong>\u3002\u5176\u4e2d\uff0cNumPy\u5e93\u662f\u5904\u7406\u77e9\u9635\u548c\u591a\u7ef4\u6570\u7ec4\u7684\u5f3a\u5927\u5de5\u5177\uff0c\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u77e9\u9635\u8fd0\u7b97\u529f\u80fd\u3002\u4f7f\u7528NumPy\u5e93\u5b9a\u4e49\u77e9\u9635\u4e0d\u4ec5\u7b80\u5355\u76f4\u89c2\uff0c\u800c\u4e14\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u51fd\u6570\u548c\u65b9\u6cd5\u6765\u64cd\u4f5c\u548c\u8ba1\u7b97\u77e9\u9635\u3002\u4f8b\u5982\uff0c\u5b9a\u4e49\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u53ea\u9700\u4f7f\u7528<code>numpy.array()<\/code>\u51fd\u6570\u5373\u53ef\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7\u8fd9\u51e0\u79cd\u65b9\u6cd5\u5b9a\u4e49\u548c\u64cd\u4f5c\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528\u5217\u8868\u5d4c\u5957\u5b9a\u4e49\u77e9\u9635<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u6700\u7b80\u5355\u7684\u65b9\u5f0f\u662f\u4f7f\u7528\u5d4c\u5957\u5217\u8868\u6765\u5b9a\u4e49\u77e9\u9635\u3002\u5d4c\u5957\u5217\u8868\u7684\u6bcf\u4e2a\u5b50\u5217\u8868\u4ee3\u8868\u77e9\u9635\u7684\u4e00\u884c\uff0c\u8fd9\u79cd\u65b9\u6cd5\u7b80\u5355\u6613\u61c2\uff0c\u9002\u5408\u5c0f\u578b\u77e9\u9635\u7684\u5b9a\u4e49\u548c\u64cd\u4f5c\u3002\u7136\u800c\uff0c\u5217\u8868\u5d4c\u5957\u7684\u64cd\u4f5c\u6548\u7387\u76f8\u5bf9\u8f83\u4f4e\uff0c\u7279\u522b\u662f\u5728\u8fdb\u884c\u590d\u6742\u7684\u77e9\u9635\u8fd0\u7b97\u65f6\uff0c\u4ee3\u7801\u53ef\u80fd\u4f1a\u53d8\u5f97\u5197\u957f\u4e14\u96be\u4ee5\u7ef4\u62a4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528\u5217\u8868\u5d4c\u5957\u5b9a\u4e49\u4e00\u4e2a3x3\u77e9\u9635<\/p>\n<p>matrix = [<\/p>\n<p>    [1, 2, 3],<\/p>\n<p>    [4, 5, 6],<\/p>\n<p>    [7, 8, 9]<\/p>\n<p>]<\/p>\n<h2><strong>\u8bbf\u95ee\u77e9\u9635\u4e2d\u7684\u5143\u7d20<\/strong><\/h2>\n<p>element = matrix[1][2]  # \u83b7\u53d6\u7b2c\u4e8c\u884c\u7b2c\u4e09\u5217\u7684\u5143\u7d20\uff0c\u8f93\u51fa\u4e3a6<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u5904\u7406\u5c0f\u578b\u6570\u636e\u96c6\u6216\u8fdb\u884c\u7b80\u5355\u7684\u77e9\u9635\u8fd0\u7b97\u65f6\uff0c\u5217\u8868\u5d4c\u5957\u662f\u4e00\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\u3002\u7136\u800c\uff0c\u5f53\u77e9\u9635\u89c4\u6a21\u6269\u5927\u6216\u9700\u8981\u8fdb\u884c\u590d\u6742\u8fd0\u7b97\u65f6\uff0c\u5efa\u8bae\u4f7f\u7528\u4e13\u95e8\u7684\u5e93\u6765\u63d0\u9ad8\u6548\u7387\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u5229\u7528NumPy\u5e93\u5b9a\u4e49\u77e9\u9635<\/p>\n<\/p>\n<p><p>NumPy\u662fPython\u4e2d\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u7684\u57fa\u7840\u5e93\u3002\u5b83\u652f\u6301\u591a\u7ef4\u6570\u7ec4\u5bf9\u8c61\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u51fd\u6570\u6765\u8fdb\u884c\u5feb\u901f\u7684\u6570\u7ec4\u8fd0\u7b97\u3002\u4f7f\u7528NumPy\u5b9a\u4e49\u77e9\u9635\u4e0d\u4ec5\u7b80\u6d01\uff0c\u800c\u4e14\u9ad8\u6548\uff0c\u662f\u5904\u7406\u5927\u578b\u77e9\u9635\u8fd0\u7b97\u7684\u9996\u9009\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u4f7f\u7528NumPy\u5b9a\u4e49\u4e00\u4e2a3x3\u77e9\u9635<\/strong><\/h2>\n<p>matrix = np.array([<\/p>\n<p>    [1, 2, 3],<\/p>\n<p>    [4, 5, 6],<\/p>\n<p>    [7, 8, 9]<\/p>\n<p>])<\/p>\n<h2><strong>\u8bbf\u95ee\u77e9\u9635\u4e2d\u7684\u5143\u7d20<\/strong><\/h2>\n<p>element = matrix[1, 2]  # \u83b7\u53d6\u7b2c\u4e8c\u884c\u7b2c\u4e09\u5217\u7684\u5143\u7d20\uff0c\u8f93\u51fa\u4e3a6<\/p>\n<h2><strong>\u77e9\u9635\u7684\u57fa\u672c\u8fd0\u7b97<\/strong><\/h2>\n<p>transpose_matrix = matrix.T  # \u77e9\u9635\u8f6c\u7f6e<\/p>\n<p>sum_of_elements = matrix.sum()  # \u77e9\u9635\u5143\u7d20\u7684\u603b\u548c<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>NumPy\u4e0d\u4ec5\u63d0\u4f9b\u4e86\u5b9a\u4e49\u77e9\u9635\u7684\u529f\u80fd\uff0c\u8fd8\u652f\u6301\u77e9\u9635\u7684\u52a0\u3001\u51cf\u3001\u4e58\u3001\u9664\u7b49\u57fa\u672c\u8fd0\u7b97\uff0c\u4ee5\u53ca\u77e9\u9635\u7684\u8f6c\u7f6e\u3001\u6c42\u9006\u7b49\u9ad8\u7ea7\u8fd0\u7b97\u3002<\/strong>\u5bf9\u4e8e\u9700\u8981\u8fdb\u884c\u590d\u6742\u6570\u5b66\u8fd0\u7b97\u7684\u5e94\u7528\u573a\u666f\uff0cNumPy\u662f\u4e00\u4e2a\u4e0d\u53ef\u6216\u7f3a\u7684\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u8fd0\u7528Pandas\u5e93\u5b9a\u4e49\u77e9\u9635<\/p>\n<\/p>\n<p><p>Pandas\u662f\u4e00\u4e2a\u6570\u636e\u5206\u6790\u5e93\uff0c\u63d0\u4f9b\u4e86DataFrame\u6570\u636e\u7ed3\u6784\uff0c\u53ef\u4ee5\u7528\u6765\u5904\u7406\u4e8c\u7ef4\u6570\u636e\u96c6\u3002\u867d\u7136Pandas\u4e3b\u8981\u7528\u4e8e\u6570\u636e\u5206\u6790\uff0c\u4f46\u4e5f\u53ef\u4ee5\u7528\u6765\u5b9a\u4e49\u548c\u64cd\u4f5c\u77e9\u9635\uff0c\u7279\u522b\u662f\u5728\u9700\u8981\u5bf9\u77e9\u9635\u8fdb\u884c\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u65f6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u4f7f\u7528Pandas\u5b9a\u4e49\u4e00\u4e2a3x3\u77e9\u9635<\/strong><\/h2>\n<p>matrix = pd.DataFrame({<\/p>\n<p>    &#39;A&#39;: [1, 2, 3],<\/p>\n<p>    &#39;B&#39;: [4, 5, 6],<\/p>\n<p>    &#39;C&#39;: [7, 8, 9]<\/p>\n<p>})<\/p>\n<h2><strong>\u8bbf\u95ee\u77e9\u9635\u4e2d\u7684\u5143\u7d20<\/strong><\/h2>\n<p>element = matrix.loc[1, &#39;C&#39;]  # \u83b7\u53d6\u7b2c\u4e8c\u884c\u7b2c\u4e09\u5217\u7684\u5143\u7d20\uff0c\u8f93\u51fa\u4e3a6<\/p>\n<h2><strong>\u77e9\u9635\u7684\u57fa\u672c\u8fd0\u7b97<\/strong><\/h2>\n<p>sum_of_columns = matrix.sum()  # \u6bcf\u5217\u5143\u7d20\u7684\u603b\u548c<\/p>\n<p>mean_of_columns = matrix.mean()  # \u6bcf\u5217\u5143\u7d20\u7684\u5e73\u5747\u503c<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>Pandas\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6570\u636e\u5904\u7406\u529f\u80fd\uff0c\u9002\u7528\u4e8e\u9700\u8981\u5bf9\u77e9\u9635\u8fdb\u884c\u6570\u636e\u6e05\u6d17\u3001\u8f6c\u6362\u548c\u5206\u6790\u7684\u573a\u666f\u3002\u4e0eNumPy\u4e0d\u540c\uff0cPandas\u66f4\u52a0\u6ce8\u91cd\u6570\u636e\u7684\u6807\u7b7e\u5316\u548c\u7ed3\u6784\u5316\u5904\u7406\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u77e9\u9635\u8fd0\u7b97\u7684\u5e94\u7528<\/p>\n<\/p>\n<p><p>\u5728\u79d1\u5b66\u8ba1\u7b97\u3001\u6570\u636e\u5206\u6790\u3001<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u7b49\u9886\u57df\uff0c\u77e9\u9635\u8fd0\u7b97\u662f\u4e0d\u53ef\u6216\u7f3a\u7684\u57fa\u7840\u3002Python\u63d0\u4f9b\u7684\u8fd9\u4e9b\u5de5\u5177\u548c\u65b9\u6cd5\uff0c\u5927\u5927\u7b80\u5316\u4e86\u77e9\u9635\u7684\u5b9a\u4e49\u548c\u8fd0\u7b97\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u77e9\u9635\u52a0\u51cf\u8fd0\u7b97<\/strong><\/li>\n<\/ol>\n<p><p>\u77e9\u9635\u7684\u52a0\u51cf\u8fd0\u7b97\u662f\u6700\u57fa\u672c\u7684\u77e9\u9635\u8fd0\u7b97\uff0cNumPy\u63d0\u4f9b\u4e86\u7b80\u5355\u6613\u7528\u7684\u63a5\u53e3\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u77e9\u9635\u52a0\u6cd5<\/p>\n<p>matrix1 = np.array([[1, 2], [3, 4]])<\/p>\n<p>matrix2 = np.array([[5, 6], [7, 8]])<\/p>\n<p>result_add = matrix1 + matrix2<\/p>\n<h2><strong>\u77e9\u9635\u51cf\u6cd5<\/strong><\/h2>\n<p>result_sub = matrix1 - matrix2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u77e9\u9635\u4e58\u6cd5<\/strong><\/li>\n<\/ol>\n<p><p>\u77e9\u9635\u4e58\u6cd5\u5728\u6570\u5b66\u548c\u5de5\u7a0b\u8ba1\u7b97\u4e2d\u5e94\u7528\u5e7f\u6cdb\u3002NumPy\u7684<code>dot<\/code>\u51fd\u6570\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u77e9\u9635\u4e58\u6cd5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u77e9\u9635\u4e58\u6cd5<\/p>\n<p>result_mul = np.dot(matrix1, matrix2)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u77e9\u9635\u6c42\u9006<\/strong><\/li>\n<\/ol>\n<p><p>\u77e9\u9635\u6c42\u9006\u5728\u89e3\u7ebf\u6027\u65b9\u7a0b\u7ec4\u3001\u8ba1\u7b97\u7ebf\u6027\u53d8\u6362\u7b49\u573a\u5408\u975e\u5e38\u91cd\u8981\u3002NumPy\u7684<code>linalg.inv<\/code>\u51fd\u6570\u53ef\u4ee5\u6c42\u5f97\u77e9\u9635\u7684\u9006\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u77e9\u9635\u6c42\u9006<\/p>\n<p>inverse_matrix = np.linalg.inv(matrix1)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li><strong>\u77e9\u9635\u7279\u5f81\u503c\u548c\u7279\u5f81\u5411\u91cf<\/strong><\/li>\n<\/ol>\n<p><p>\u7279\u5f81\u503c\u548c\u7279\u5f81\u5411\u91cf\u5728\u6570\u636e\u964d\u7ef4\u548c\u6a21\u5f0f\u8bc6\u522b\u4e2d\u53d1\u6325\u91cd\u8981\u4f5c\u7528\u3002NumPy\u7684<code>linalg.eig<\/code>\u51fd\u6570\u53ef\u4ee5\u8ba1\u7b97\u77e9\u9635\u7684\u7279\u5f81\u503c\u548c\u7279\u5f81\u5411\u91cf\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u77e9\u9635\u7279\u5f81\u503c\u548c\u7279\u5f81\u5411\u91cf<\/p>\n<p>eigenvalues, eigenvectors = np.linalg.eig(matrix1)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e94\u3001\u5b9e\u9645\u5e94\u7528\u6848\u4f8b<\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u66f4\u597d\u5730\u7406\u89e3Python\u77e9\u9635\u7684\u5b9a\u4e49\u548c\u8fd0\u7b97\uff0c\u6211\u4eec\u53ef\u4ee5\u7ed3\u5408\u5b9e\u9645\u5e94\u7528\u6848\u4f8b\u8fdb\u884c\u8bf4\u660e\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u56fe\u50cf\u5904\u7406<\/strong><\/li>\n<\/ol>\n<p><p>\u5728\u56fe\u50cf\u5904\u7406\u4e2d\uff0c\u56fe\u50cf\u53ef\u4ee5\u88ab\u770b\u4f5c\u662f\u4e00\u4e2a\u50cf\u7d20\u77e9\u9635\u3002\u901a\u8fc7\u5bf9\u50cf\u7d20\u77e9\u9635\u8fdb\u884c\u8fd0\u7b97\uff0c\u53ef\u4ee5\u5b9e\u73b0\u56fe\u50cf\u7684\u65cb\u8f6c\u3001\u7f29\u653e\u3001\u6ee4\u6ce2\u7b49\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from scipy import ndimage<\/p>\n<h2><strong>\u8bfb\u53d6\u56fe\u50cf\u5e76\u8f6c\u6362\u4e3a\u77e9\u9635<\/strong><\/h2>\n<p>image_matrix = ndimage.imread(&#39;example.jpg&#39;, mode=&#39;L&#39;)<\/p>\n<h2><strong>\u56fe\u50cf\u65cb\u8f6c<\/strong><\/h2>\n<p>rotated_image = ndimage.rotate(image_matrix, 45)<\/p>\n<h2><strong>\u4fdd\u5b58\u5904\u7406\u540e\u7684\u56fe\u50cf<\/strong><\/h2>\n<p>ndimage.imsave(&#39;rotated_example.jpg&#39;, rotated_image)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u673a\u5668\u5b66\u4e60<\/strong><\/li>\n<\/ol>\n<p><p>\u5728\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u6570\u636e\u96c6\u901a\u5e38\u88ab\u8868\u793a\u4e3a\u4e00\u4e2a\u77e9\u9635\uff0c\u5176\u4e2d\u884c\u4ee3\u8868\u6837\u672c\uff0c\u5217\u4ee3\u8868\u7279\u5f81\u3002\u901a\u8fc7\u77e9\u9635\u8fd0\u7b97\uff0c\u53ef\u4ee5\u5b9e\u73b0\u7ebf\u6027\u56de\u5f52\u3001\u4e3b\u6210\u5206\u5206\u6790\u7b49\u7b97\u6cd5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.linear_model import LinearRegression<\/p>\n<h2><strong>\u5b9a\u4e49\u6837\u672c\u7279\u5f81\u548c\u76ee\u6807\u503c<\/strong><\/h2>\n<p>X = np.array([[1, 2], [2, 3], [3, 4]])<\/p>\n<p>y = np.array([5, 7, 9])<\/p>\n<h2><strong>\u521b\u5efa\u7ebf\u6027\u56de\u5f52\u6a21\u578b<\/strong><\/h2>\n<p>model = LinearRegression()<\/p>\n<p>model.fit(X, y)<\/p>\n<h2><strong>\u9884\u6d4b<\/strong><\/h2>\n<p>predictions = model.predict(X)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516d\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>Python\u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u5b9a\u4e49\u548c\u64cd\u4f5c\u77e9\u9635\uff0c<strong>\u5305\u62ec\u4f7f\u7528\u5217\u8868\u5d4c\u5957\u3001NumPy\u5e93\u548cPandas\u5e93<\/strong>\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u9002\u7528\u7684\u573a\u666f\u548c\u4f18\u7f3a\u70b9\u3002\u5728\u8fdb\u884c\u77e9\u9635\u8fd0\u7b97\u65f6\uff0cNumPy\u7531\u4e8e\u5176\u9ad8\u6548\u6027\u548c\u7b80\u6d01\u6027\uff0c\u901a\u5e38\u662f\u9996\u9009\u5de5\u5177\u3002\u6b64\u5916\uff0c\u7ed3\u5408\u5b9e\u9645\u5e94\u7528\u6848\u4f8b\uff0c\u53ef\u4ee5\u66f4\u52a0\u76f4\u89c2\u5730\u7406\u89e3\u77e9\u9635\u8fd0\u7b97\u5728\u4e0d\u540c\u9886\u57df\u4e2d\u7684\u5e94\u7528\u3002\u65e0\u8bba\u662f\u5728\u79d1\u5b66\u8ba1\u7b97\u3001\u56fe\u50cf\u5904\u7406\u8fd8\u662f\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u638c\u63e1\u77e9\u9635\u7684\u5b9a\u4e49\u548c\u8fd0\u7b97\u90fd\u662f\u975e\u5e38\u91cd\u8981\u7684\u6280\u80fd\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u521b\u5efa\u4e00\u4e2a\u77e9\u9635\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u77e9\u9635\u901a\u5e38\u4f7f\u7528\u5d4c\u5957\u5217\u8868\u6216NumPy\u5e93\u6765\u5b9a\u4e49\u3002\u4f7f\u7528\u5d4c\u5957\u5217\u8868\u7684\u65b9\u5f0f\u662f\u5c06\u5217\u8868\u4f5c\u4e3a\u5143\u7d20\u653e\u5165\u53e6\u4e00\u4e2a\u5217\u8868\u4e2d\uff0c\u4f8b\u5982\uff1a<code>matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]<\/code>\u3002\u5982\u679c\u4f7f\u7528NumPy\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7<code>numpy.array()<\/code>\u51fd\u6570\u6765\u521b\u5efa\uff0c\u4f8b\u5982\uff1a<code>import numpy as np; matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])<\/code>\u3002<\/p>\n<p><strong>Python\u4e2d\u5982\u4f55\u8fdb\u884c\u77e9\u9635\u8fd0\u7b97\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u77e9\u9635\u8fd0\u7b97\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\u6765\u5904\u7406\u77e9\u9635\u3002\u5e38\u89c1\u7684\u64cd\u4f5c\u5305\u62ec\u77e9\u9635\u52a0\u6cd5\u3001\u51cf\u6cd5\u3001\u4e58\u6cd5\u548c\u8f6c\u7f6e\u7b49\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>np.add()<\/code>\u8fdb\u884c\u52a0\u6cd5\uff0c<code>np.subtract()<\/code>\u8fdb\u884c\u51cf\u6cd5\uff0c\u4f7f\u7528<code>np.dot()<\/code>\u8fdb\u884c\u77e9\u9635\u4e58\u6cd5\uff0c\u4f7f\u7528<code>matrix.T<\/code>\u8fdb\u884c\u8f6c\u7f6e\u3002\u8fd9\u4e9b\u64cd\u4f5c\u90fd\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5b9a\u4e49\u77e9\u9635\u65f6\u6709\u4ec0\u4e48\u6ce8\u610f\u4e8b\u9879\uff1f<\/strong><br \/>\u5728\u5b9a\u4e49\u77e9\u9635\u65f6\uff0c\u9700\u8981\u786e\u4fdd\u6240\u6709\u884c\u7684\u5143\u7d20\u6570\u91cf\u76f8\u540c\uff0c\u4ee5\u5f62\u6210\u4e00\u4e2a\u6709\u6548\u7684\u77e9\u9635\u7ed3\u6784\u3002\u5982\u679c\u4f7f\u7528NumPy\u5e93\uff0c\u53ef\u4ee5\u76f4\u63a5\u521b\u5efa\u4e0d\u89c4\u5219\u7684\u6570\u7ec4\uff0c\u4f46\u8fd9\u5c06\u4e0d\u4f1a\u88ab\u89c6\u4e3a\u77e9\u9635\u3002\u6b64\u5916\uff0c\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7c7b\u578b\u4e5f\u5f88\u91cd\u8981\uff0c\u4f8b\u5982\u6574\u578b\u3001\u6d6e\u70b9\u578b\u7b49\uff0c\u5c24\u5176\u662f\u5728\u8fdb\u884c\u6570\u503c\u8ba1\u7b97\u65f6\uff0c\u907f\u514d\u51fa\u73b0\u7cbe\u5ea6\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u5b9a\u4e49\u77e9\u9635\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u6700\u5e38\u7528\u7684\u5305\u62ec\u4f7f\u7528\u5217\u8868\u5d4c\u5957\u3001\u5229\u7528NumPy\u5e93\u3001\u8fd0\u7528Pandas\u5e93\u3002\u5176\u4e2d\uff0cNu [&hellip;]","protected":false},"author":3,"featured_media":922043,"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\/922038"}],"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=922038"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/922038\/revisions"}],"predecessor-version":[{"id":922045,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/922038\/revisions\/922045"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/922043"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=922038"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=922038"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=922038"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}