{"id":1119848,"date":"2025-01-08T18:48:33","date_gmt":"2025-01-08T10:48:33","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1119848.html"},"modified":"2025-01-08T18:48:35","modified_gmt":"2025-01-08T10:48:35","slug":"python%e5%a6%82%e4%bd%95%e5%af%b9%e7%89%b9%e5%be%81%e5%9b%be%e8%ae%a1%e7%ae%97%e5%8d%8f%e6%96%b9%e5%b7%ae%e7%9f%a9%e9%98%b5","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1119848.html","title":{"rendered":"python\u5982\u4f55\u5bf9\u7279\u5f81\u56fe\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25082751\/a8552da0-9d85-44fd-95fa-d3ff5eb99e0a.webp\" alt=\"python\u5982\u4f55\u5bf9\u7279\u5f81\u56fe\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\" \/><\/p>\n<p><p> <strong>Python \u5bf9\u7279\u5f81\u56fe\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528numpy\u5e93\u8fdb\u884c\u77e9\u9635\u64cd\u4f5c\u3001\u4f7f\u7528Pandas\u5e93\u8fdb\u884c\u6570\u636e\u5904\u7406\u3001\u5229\u7528SciPy\u5e93\u8fdb\u884c\u9ad8\u7ea7\u77e9\u9635\u8fd0\u7b97\u3002<\/strong>\u5176\u4e2d\uff0c\u5229\u7528numpy\u5e93\u8fdb\u884c\u77e9\u9635\u64cd\u4f5c\u662f\u4e00\u79cd\u5e38\u89c1\u4e14\u9ad8\u6548\u7684\u65b9\u6cd5\u3002\u4e0b\u9762\u5c06\u5bf9\u5229\u7528numpy\u5e93\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\u7684\u65b9\u6cd5\u8fdb\u884c\u8be6\u7ec6\u63cf\u8ff0\u3002<\/p>\n<\/p>\n<p><p>\u5728\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\u65f6\uff0c\u9996\u5148\u9700\u8981\u7406\u89e3\u4ec0\u4e48\u662f\u534f\u65b9\u5dee\u77e9\u9635\u3002\u534f\u65b9\u5dee\u77e9\u9635\u662f\u4e00\u4e2a\u65b9\u9635\uff0c\u5b83\u7684\u5143\u7d20\u662f\u6570\u636e\u96c6\u4e2d\u6bcf\u5bf9\u7279\u5f81\u4e4b\u95f4\u7684\u534f\u65b9\u5dee\uff0c\u534f\u65b9\u5dee\u53cd\u6620\u4e86\u4e24\u4e2a\u53d8\u91cf\u95f4\u7684\u7ebf\u6027\u5173\u7cfb\u3002\u5982\u679c\u534f\u65b9\u5dee\u4e3a\u6b63\u6570\uff0c\u8868\u793a\u4e24\u4e2a\u53d8\u91cf\u5448\u6b63\u76f8\u5173\u5173\u7cfb\uff1b\u5982\u679c\u4e3a\u8d1f\u6570\uff0c\u8868\u793a\u8d1f\u76f8\u5173\u5173\u7cfb\uff1b\u5982\u679c\u4e3a\u96f6\uff0c\u5219\u8868\u793a\u65e0\u76f8\u5173\u5173\u7cfb\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528numpy\u5e93\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528numpy\u5e93\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u52a0\u8f7dnumpy\u5e93<\/strong>\uff1a\u9996\u5148\u9700\u8981\u5bfc\u5165numpy\u5e93\uff0c\u8fd9\u662fPython\u4e2d\u8fdb\u884c\u6570\u503c\u8ba1\u7b97\u6700\u5e38\u7528\u7684\u5e93\u3002<\/li>\n<li><strong>\u51c6\u5907\u6570\u636e<\/strong>\uff1a\u5c06\u7279\u5f81\u56fe\u6574\u7406\u4e3anumpy\u6570\u7ec4\u5f62\u5f0f\uff0c\u786e\u4fdd\u6bcf\u4e00\u884c\u4ee3\u8868\u4e00\u4e2a\u6837\u672c\uff0c\u6bcf\u4e00\u5217\u4ee3\u8868\u4e00\u4e2a\u7279\u5f81\u3002<\/li>\n<li><strong>\u8ba1\u7b97\u5747\u503c<\/strong>\uff1a\u8ba1\u7b97\u6bcf\u4e2a\u7279\u5f81\u7684\u5747\u503c\u3002<\/li>\n<li><strong>\u4e2d\u5fc3\u5316\u6570\u636e<\/strong>\uff1a\u5c06\u6bcf\u4e2a\u7279\u5f81\u51cf\u53bb\u5b83\u7684\u5747\u503c\uff0c\u4f7f\u6570\u636e\u4e2d\u5fc3\u5316\u3002<\/li>\n<li><strong>\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635<\/strong>\uff1a\u4f7f\u7528numpy\u7684 <code>np.cov<\/code> \u51fd\u6570\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\u3002<\/li>\n<\/ol>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u7279\u5f81\u56fe\u6570\u636e\uff0cshape\u4e3a(samples, features)<\/strong><\/h2>\n<p>data = np.array([[2.5, 3.0, 3.5],<\/p>\n<p>                 [3.0, 3.5, 4.0],<\/p>\n<p>                 [3.5, 4.0, 4.5],<\/p>\n<p>                 [4.0, 4.5, 5.0],<\/p>\n<p>                 [4.5, 5.0, 5.5]])<\/p>\n<h2><strong>\u8ba1\u7b97\u6bcf\u4e2a\u7279\u5f81\u7684\u5747\u503c<\/strong><\/h2>\n<p>mean_vector = np.mean(data, axis=0)<\/p>\n<h2><strong>\u4e2d\u5fc3\u5316\u6570\u636e<\/strong><\/h2>\n<p>centered_data = data - mean_vector<\/p>\n<h2><strong>\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635<\/strong><\/h2>\n<p>cov_matrix = np.cov(centered_data, rowvar=False)<\/p>\n<p>print(&quot;\u534f\u65b9\u5dee\u77e9\u9635:\\n&quot;, cov_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c<code>np.mean<\/code> \u51fd\u6570\u8ba1\u7b97\u6bcf\u4e2a\u7279\u5f81\u7684\u5747\u503c\uff0c<code>centered_data = data - mean_vector<\/code> \u5c06\u6570\u636e\u4e2d\u5fc3\u5316\uff0c\u6700\u540e <code>np.cov(centered_data, rowvar=False)<\/code> \u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\u3002<code>rowvar=False<\/code> \u53c2\u6570\u8868\u793a\u6bcf\u5217\u4ee3\u8868\u4e00\u4e2a\u7279\u5f81\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528Pandas\u5e93\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635<\/h3>\n<\/p>\n<p><p>Pandas\u5e93\u63d0\u4f9b\u4e86\u66f4\u9ad8\u5c42\u6b21\u7684\u6570\u636e\u64cd\u4f5c\u63a5\u53e3\uff0c\u53ef\u4ee5\u66f4\u52a0\u65b9\u4fbf\u5730\u8fdb\u884c\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u3002\u4f7f\u7528Pandas\u5e93\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u52a0\u8f7dPandas\u5e93<\/strong>\uff1a\u9996\u5148\u9700\u8981\u5bfc\u5165Pandas\u5e93\u3002<\/li>\n<li><strong>\u51c6\u5907\u6570\u636e<\/strong>\uff1a\u5c06\u7279\u5f81\u56fe\u6574\u7406\u4e3aPandas DataFrame\u5f62\u5f0f\u3002<\/li>\n<li><strong>\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635<\/strong>\uff1a\u4f7f\u7528DataFrame\u7684 <code>cov<\/code> \u65b9\u6cd5\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\u3002<\/li>\n<\/ol>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u7279\u5f81\u56fe\u6570\u636e\uff0cshape\u4e3a(samples, features)<\/strong><\/h2>\n<p>data = pd.DataFrame([[2.5, 3.0, 3.5],<\/p>\n<p>                     [3.0, 3.5, 4.0],<\/p>\n<p>                     [3.5, 4.0, 4.5],<\/p>\n<p>                     [4.0, 4.5, 5.0],<\/p>\n<p>                     [4.5, 5.0, 5.5]],<\/p>\n<p>                    columns=[&#39;Feature1&#39;, &#39;Feature2&#39;, &#39;Feature3&#39;])<\/p>\n<h2><strong>\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635<\/strong><\/h2>\n<p>cov_matrix = data.cov()<\/p>\n<p>print(&quot;\u534f\u65b9\u5dee\u77e9\u9635:\\n&quot;, cov_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u9996\u5148\u5c06\u7279\u5f81\u56fe\u6570\u636e\u6574\u7406\u4e3aPandas DataFrame\u5f62\u5f0f\uff0c\u5217\u540d\u4e3a\u7279\u5f81\u540d\uff0c\u7136\u540e\u4f7f\u7528 <code>data.cov()<\/code> \u76f4\u63a5\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5229\u7528SciPy\u5e93\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635<\/h3>\n<\/p>\n<p><p>SciPy\u5e93\u662f\u4e00\u4e2a\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u7684Python\u5e93\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u9ad8\u7ea7\u77e9\u9635\u8fd0\u7b97\u529f\u80fd\u3002\u4f7f\u7528SciPy\u5e93\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u52a0\u8f7dSciPy\u5e93<\/strong>\uff1a\u9996\u5148\u9700\u8981\u5bfc\u5165SciPy\u5e93\u3002<\/li>\n<li><strong>\u51c6\u5907\u6570\u636e<\/strong>\uff1a\u5c06\u7279\u5f81\u56fe\u6574\u7406\u4e3anumpy\u6570\u7ec4\u5f62\u5f0f\u3002<\/li>\n<li><strong>\u4f7f\u7528SciPy\u51fd\u6570\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635<\/strong>\uff1a\u5229\u7528SciPy\u63d0\u4f9b\u7684\u51fd\u6570\u8fdb\u884c\u8ba1\u7b97\u3002<\/li>\n<\/ol>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>from scipy import linalg<\/p>\n<h2><strong>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u7279\u5f81\u56fe\u6570\u636e\uff0cshape\u4e3a(samples, features)<\/strong><\/h2>\n<p>data = np.array([[2.5, 3.0, 3.5],<\/p>\n<p>                 [3.0, 3.5, 4.0],<\/p>\n<p>                 [3.5, 4.0, 4.5],<\/p>\n<p>                 [4.0, 4.5, 5.0],<\/p>\n<p>                 [4.5, 5.0, 5.5]])<\/p>\n<h2><strong>\u8ba1\u7b97\u6bcf\u4e2a\u7279\u5f81\u7684\u5747\u503c<\/strong><\/h2>\n<p>mean_vector = np.mean(data, axis=0)<\/p>\n<h2><strong>\u4e2d\u5fc3\u5316\u6570\u636e<\/strong><\/h2>\n<p>centered_data = data - mean_vector<\/p>\n<h2><strong>\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635<\/strong><\/h2>\n<p>cov_matrix = np.dot(centered_data.T, centered_data) \/ (data.shape[0] - 1)<\/p>\n<p>print(&quot;\u534f\u65b9\u5dee\u77e9\u9635:\\n&quot;, cov_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528 <code>np.dot<\/code> \u51fd\u6570\u8ba1\u7b97\u4e2d\u5fc3\u5316\u6570\u636e\u7684\u8f6c\u7f6e\u4e0e\u4e2d\u5fc3\u5316\u6570\u636e\u7684\u4e58\u79ef\uff0c\u518d\u9664\u4ee5\u6837\u672c\u6570\u51cf\u4e00\uff0c\u5f97\u5230\u534f\u65b9\u5dee\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u534f\u65b9\u5dee\u77e9\u9635\u7684\u5e94\u7528<\/h3>\n<\/p>\n<p><p>\u534f\u65b9\u5dee\u77e9\u9635\u5728\u6570\u636e\u5206\u6790\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u4e2d\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\uff0c\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u7279\u5f81\u9009\u62e9<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u5206\u6790\u534f\u65b9\u5dee\u77e9\u9635\uff0c\u53ef\u4ee5\u53d1\u73b0\u54ea\u4e9b\u7279\u5f81\u4e4b\u95f4\u5b58\u5728\u9ad8\u5ea6\u76f8\u5173\u6027\u3002\u5982\u679c\u4e24\u4e2a\u7279\u5f81\u7684\u534f\u65b9\u5dee\u503c\u5f88\u9ad8\uff0c\u5219\u53ef\u4ee5\u8003\u8651\u53bb\u6389\u5176\u4e2d\u4e00\u4e2a\u7279\u5f81\uff0c\u4ee5\u51cf\u5c11\u5197\u4f59\u7279\u5f81\uff0c\u63d0\u9ad8\u6a21\u578b\u7684\u8bad\u7ec3\u6548\u7387\u548c\u9884\u6d4b\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u4e3b\u6210\u5206\u5206\u6790\uff08PCA\uff09<\/h4>\n<\/p>\n<p><p>\u4e3b\u6210\u5206\u5206\u6790\u662f\u4e00\u79cd\u964d\u7ef4\u6280\u672f\uff0c\u901a\u8fc7\u8ba1\u7b97\u6570\u636e\u7684\u534f\u65b9\u5dee\u77e9\u9635\uff0c\u627e\u5230\u6570\u636e\u7684\u4e3b\u6210\u5206\uff0c\u4ece\u800c\u5c06\u9ad8\u7ef4\u6570\u636e\u8f6c\u6362\u4e3a\u4f4e\u7ef4\u6570\u636e\u3002\u534f\u65b9\u5dee\u77e9\u9635\u5728PCA\u4e2d\u7684\u4f5c\u7528\u662f\u7528\u4e8e\u8ba1\u7b97\u7279\u5f81\u503c\u548c\u7279\u5f81\u5411\u91cf\uff0c\u4ee5\u786e\u5b9a\u4e3b\u6210\u5206\u7684\u65b9\u5411\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u6570\u636e\u5efa\u6a21<\/h4>\n<\/p>\n<p><p>\u5728\u4e00\u4e9b\u7edf\u8ba1\u5efa\u6a21\u65b9\u6cd5\u4e2d\uff0c\u5982\u591a\u5143\u7ebf\u6027\u56de\u5f52\u548c\u8d1d\u53f6\u65af\u7f51\u7edc\uff0c\u534f\u65b9\u5dee\u77e9\u9635\u88ab\u7528\u6765\u63cf\u8ff0\u53d8\u91cf\u4e4b\u95f4\u7684\u76f8\u5173\u6027\uff0c\u4ece\u800c\u66f4\u51c6\u786e\u5730\u5efa\u6a21\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u8ba1\u7b97\u7279\u5f81\u56fe\u7684\u534f\u65b9\u5dee\u77e9\u9635\u662f\u6570\u636e\u5206\u6790\u548c\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u6b65\u9aa4\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u4f7f\u7528numpy\u3001Pandas\u548cSciPy\u5e93\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\u7684\u65b9\u6cd5\uff0c\u5e76\u8be6\u7ec6\u63cf\u8ff0\u4e86\u6bcf\u79cd\u65b9\u6cd5\u7684\u5b9e\u73b0\u6b65\u9aa4\u3002\u901a\u8fc7\u5bf9\u534f\u65b9\u5dee\u77e9\u9635\u7684\u5206\u6790\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u7406\u89e3\u6570\u636e\u7684\u7ed3\u6784\uff0c\u8fdb\u884c\u7279\u5f81\u9009\u62e9\u3001\u4e3b\u6210\u5206\u5206\u6790\u7b49\u64cd\u4f5c\uff0c\u4ece\u800c\u63d0\u9ad8\u6a21\u578b\u7684\u6027\u80fd\u548c\u6548\u7387\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u9002\u5408\u7684\u65b9\u6cd5\u8fdb\u884c\u534f\u65b9\u5dee\u77e9\u9635\u7684\u8ba1\u7b97\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8ba1\u7b97\u7279\u5f81\u56fe\u7684\u534f\u65b9\u5dee\u77e9\u9635\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u6765\u8ba1\u7b97\u7279\u5f81\u56fe\u7684\u534f\u65b9\u5dee\u77e9\u9635\u3002\u9996\u5148\uff0c\u5c06\u7279\u5f81\u56fe\u6570\u636e\u6574\u7406\u4e3a\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\uff0c\u5176\u4e2d\u6bcf\u4e00\u884c\u4ee3\u8868\u4e00\u4e2a\u6837\u672c\uff0c\u6bcf\u4e00\u5217\u4ee3\u8868\u4e00\u4e2a\u7279\u5f81\u3002\u7136\u540e\uff0c\u4f7f\u7528NumPy\u7684<code>np.cov()<\/code>\u51fd\u6570\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\u3002\u786e\u4fdd\u5728\u8c03\u7528\u51fd\u6570\u65f6\u8bbe\u7f6e\u53c2\u6570<code>rowvar=False<\/code>\uff0c\u4ee5\u4fbf\u6309\u5217\u8ba1\u7b97\u534f\u65b9\u5dee\u3002<\/p>\n<p><strong>\u7279\u5f81\u56fe\u7684\u534f\u65b9\u5dee\u77e9\u9635\u6709\u54ea\u4e9b\u5b9e\u9645\u5e94\u7528\uff1f<\/strong><br \/>\u534f\u65b9\u5dee\u77e9\u9635\u5728\u6570\u636e\u5206\u6790\u3001\u673a\u5668\u5b66\u4e60\u548c\u7edf\u8ba1\u5b66\u4e2d\u6709\u5e7f\u6cdb\u5e94\u7528\u3002\u5b83\u53ef\u4ee5\u5e2e\u52a9\u7406\u89e3\u7279\u5f81\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u8bc6\u522b\u7279\u5f81\u7684\u76f8\u5173\u6027\uff0c\u5e76\u5728\u964d\u7ef4\u6280\u672f\uff08\u5982\u4e3b\u6210\u5206\u5206\u6790\uff09\u4e2d\u8d77\u5230\u5173\u952e\u4f5c\u7528\u3002\u901a\u8fc7\u5206\u6790\u534f\u65b9\u5dee\u77e9\u9635\uff0c\u53ef\u4ee5\u53d1\u73b0\u6570\u636e\u7684\u6f5c\u5728\u7ed3\u6784\uff0c\u4ece\u800c\u4f18\u5316\u6a21\u578b\u6027\u80fd\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u7279\u5f81\u56fe\u4e2d\u7f3a\u5931\u503c\u5bf9\u534f\u65b9\u5dee\u77e9\u9635\u7684\u5f71\u54cd\uff1f<\/strong><br \/>\u7f3a\u5931\u503c\u4f1a\u5f71\u54cd\u534f\u65b9\u5dee\u77e9\u9635\u7684\u8ba1\u7b97\uff0c\u5bfc\u81f4\u4e0d\u51c6\u786e\u7684\u7ed3\u679c\u3002\u5728\u5904\u7406\u7279\u5f81\u56fe\u65f6\uff0c\u53ef\u4ee5\u9009\u62e9\u586b\u8865\u7f3a\u5931\u503c\uff08\u5982\u4f7f\u7528\u5747\u503c\u6216\u4e2d\u4f4d\u6570\u63d2\u8865\uff09\u6216\u76f4\u63a5\u5220\u9664\u5305\u542b\u7f3a\u5931\u503c\u7684\u6837\u672c\u3002\u4f7f\u7528Pandas\u5e93\u4e2d\u7684<code>fillna()<\/code>\u6216<code>dropna()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u6709\u6548\u5904\u7406\u8fd9\u4e9b\u95ee\u9898\uff0c\u786e\u4fdd\u8ba1\u7b97\u51fa\u7684\u534f\u65b9\u5dee\u77e9\u9635\u66f4\u5177\u4ee3\u8868\u6027\u548c\u51c6\u786e\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python \u5bf9\u7279\u5f81\u56fe\u8ba1\u7b97\u534f\u65b9\u5dee\u77e9\u9635\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528numpy\u5e93\u8fdb\u884c\u77e9\u9635\u64cd\u4f5c\u3001\u4f7f\u7528Pandas\u5e93\u8fdb\u884c\u6570\u636e\u5904\u7406\u3001 [&hellip;]","protected":false},"author":3,"featured_media":1119859,"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\/1119848"}],"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=1119848"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1119848\/revisions"}],"predecessor-version":[{"id":1119863,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1119848\/revisions\/1119863"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1119859"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1119848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1119848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1119848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}