{"id":1017492,"date":"2024-12-27T12:29:29","date_gmt":"2024-12-27T04:29:29","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1017492.html"},"modified":"2024-12-27T12:30:22","modified_gmt":"2024-12-27T04:30:22","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e6%89%93%e5%87%banan","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1017492.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u6253\u51faNaN"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25160340\/89b5c4cd-cbb2-4d88-b089-156731563549.webp\" alt=\"python\u4e2d\u5982\u4f55\u6253\u51faNaN\" \/><\/p>\n<p><p> \u5728Python\u4e2d\uff0c<strong>\u53ef\u4ee5\u901a\u8fc7NumPy\u5e93\u6216Pandas\u5e93\u6765\u6253\u51faNaN<\/strong>\u3002NumPy\u7684 <code>numpy.nan<\/code> \u548c Pandas\u7684 <code>pandas.NA<\/code> \u662f\u4e24\u79cd\u5e38\u89c1\u7684\u65b9\u6cd5\u3002\u5176\u4e2d\uff0cNumPy\u7684 <code>numpy.nan<\/code> \u662f\u4e00\u4e2a\u6d6e\u70b9\u7c7b\u578b\u7684NaN\u503c\uff0c\u800cPandas\u7684 <code>pandas.NA<\/code> \u662f\u4e00\u79cd\u65b0\u7684\u7f3a\u5931\u503c\u6807\u8bb0\uff0c\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u6570\u636e\u7c7b\u578b\u3002<strong>\u9009\u62e9\u4f7f\u7528NumPy\u7684 <code>numpy.nan<\/code> \u6216 Pandas\u7684 <code>pandas.NA<\/code>\uff0c\u53d6\u51b3\u4e8e\u4f60\u7684\u5177\u4f53\u5e94\u7528\u573a\u666f<\/strong>\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u4e3b\u8981\u5728\u5904\u7406\u6570\u503c\u578b\u6570\u636e\uff0c\u4e14\u5e0c\u671b\u5229\u7528NumPy\u7684\u9ad8\u6548\u8ba1\u7b97\u529f\u80fd\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>numpy.nan<\/code>\u3002\u800c\u5982\u679c\u4f60\u5904\u7406\u7684\u662f\u6df7\u5408\u6570\u636e\u7c7b\u578b\u7684DataFrame\uff0cPandas\u7684 <code>pandas.NA<\/code> \u53ef\u80fd\u66f4\u5408\u9002\u3002<\/p>\n<\/p>\n<p><p>\u8be6\u7ec6\u6765\u8bf4\uff0c\u5982\u679c\u4f7f\u7528NumPy\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u521b\u5efaNaN\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>nan_value = np.nan<\/p>\n<p>print(nan_value)  # \u8f93\u51fa: nan<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u800c\u5728Pandas\u4e2d\uff0c\u53ef\u4ee5\u8fd9\u6837\u521b\u5efaNaN\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>na_value = pd.NA<\/p>\n<p>print(na_value)  # \u8f93\u51fa: &lt;NA&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u63a5\u4e0b\u6765\u7684\u90e8\u5206\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u63a2\u8ba8\u8fd9\u4e9b\u65b9\u6cd5\u7684\u5177\u4f53\u5e94\u7528\u573a\u666f\u53ca\u4f18\u7f3a\u70b9\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001NUMPY\u4e2d\u7684NAN<\/p>\n<\/p>\n<p><p>NumPy\u662f\u4e00\u4e2a\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u7684\u57fa\u7840\u5e93\uff0c\u5176 <code>numpy.nan<\/code> \u5e38\u7528\u4e8e\u8868\u793a\u6d6e\u70b9\u6570\u7684\u7f3a\u5931\u503c\u3002NumPy\u7684 <code>numpy.nan<\/code> \u662fIEEE\u6807\u51c6\u6d6e\u70b9\u6570\u4e2d\u7684\u4e00\u4e2a\u7279\u6b8a\u503c\uff0c\u8868\u793a\u201c\u4e0d\u662f\u4e00\u4e2a\u6570\u5b57\u201d\uff08Not a Number\uff09\u3002<\/p>\n<\/p>\n<p><h3>1. NumPy\u4e2d\u7684NaN\u7684\u4f7f\u7528<\/h3>\n<\/p>\n<p><p>\u5728NumPy\u4e2d\uff0cNaN\u53ef\u4ee5\u7528\u4e8e\u521d\u59cb\u5316\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\uff0c\u8868\u793a\u8fd9\u4e9b\u5143\u7d20\u7684\u503c\u662f\u672a\u77e5\u7684\u3002\u4f7f\u7528NaN\u7684\u4e00\u4e2a\u5e38\u89c1\u573a\u666f\u662f\u6570\u636e\u6e05\u6d17\u548c\u9884\u5904\u7406\u3002\u5728\u6570\u636e\u5206\u6790\u8fc7\u7a0b\u4e2d\uff0c\u5e38\u5e38\u9047\u5230\u7f3a\u5931\u6570\u636e\uff0c\u8fd9\u4e9b\u7f3a\u5931\u6570\u636e\u53ef\u4ee5\u7528NaN\u6765\u8868\u793a\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5305\u542bNaN\u7684\u6570\u7ec4<\/strong><\/h2>\n<p>array_with_nan = np.array([1, 2, np.nan, 4, 5])<\/p>\n<p>print(array_with_nan)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542bNaN\u503c\u7684\u4e00\u7ef4\u6570\u7ec4\u3002NaN\u503c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u65b9\u4fbf\u5730\u5904\u7406\u548c\u5206\u6790\u6570\u636e\u4e2d\u7684\u7f3a\u5931\u90e8\u5206\u3002<\/p>\n<\/p>\n<p><h3>2. NumPy\u4e2d\u7684NaN\u7684\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u5904\u7406NaN\u662f\u6570\u636e\u5206\u6790\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u90e8\u5206\u3002\u5728NumPy\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u51fd\u6570\u5982 <code>numpy.isnan()<\/code> \u6765\u68c0\u6d4bNaN\u503c\uff0c\u5e76\u4f7f\u7528 <code>numpy.nan_to_num()<\/code> \u5c06NaN\u66ff\u6362\u4e3a\u6307\u5b9a\u7684\u6570\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>array_with_nan = np.array([1, 2, np.nan, 4, 5])<\/p>\n<h2><strong>\u68c0\u6d4bNaN<\/strong><\/h2>\n<p>nan_mask = np.isnan(array_with_nan)<\/p>\n<p>print(&quot;NaN mask:&quot;, nan_mask)<\/p>\n<h2><strong>\u5c06NaN\u66ff\u6362\u4e3a0<\/strong><\/h2>\n<p>array_without_nan = np.nan_to_num(array_with_nan, nan=0.0)<\/p>\n<p>print(&quot;Array without NaN:&quot;, array_without_nan)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u4f7f\u7528 <code>numpy.isnan()<\/code> \u68c0\u6d4b\u51fa\u6570\u7ec4\u4e2dNaN\u7684\u4f4d\u7f6e\uff0c\u7136\u540e\u4f7f\u7528 <code>numpy.nan_to_num()<\/code> \u51fd\u6570\u5c06NaN\u66ff\u6362\u4e3a0.0\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001PANDAS\u4e2d\u7684NAN<\/p>\n<\/p>\n<p><p>Pandas\u662f\u4e00\u4e2a\u6570\u636e\u5206\u6790\u548c\u6570\u636e\u5904\u7406\u7684\u5f3a\u5927\u5e93\u3002\u5728Pandas\u4e2d\uff0cNaN\u503c\u53ef\u4ee5\u7528 <code>pandas.NA<\/code> \u8868\u793a\uff0c\u5b83\u662fPandas\u81ea\u5e26\u7684\u7f3a\u5931\u503c\u6807\u8bb0\uff0c\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec\u6574\u6570\u3001\u6d6e\u70b9\u6570\u3001\u5b57\u7b26\u4e32\u7b49\u3002<\/p>\n<\/p>\n<p><h3>1. Pandas\u4e2d\u7684NaN\u7684\u4f7f\u7528<\/h3>\n<\/p>\n<p><p>\u5728Pandas\u4e2d\uff0c\u521b\u5efa\u5305\u542bNaN\u503c\u7684DataFrame\u6216Series\u662f\u975e\u5e38\u7b80\u5355\u7684\u3002NaN\u503c\u53ef\u4ee5\u7528\u6765\u8868\u793aDataFrame\u6216Series\u4e2d\u7f3a\u5931\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5305\u542bNaN\u7684DataFrame<\/strong><\/h2>\n<p>data_with_nan = pd.DataFrame({<\/p>\n<p>    &#39;A&#39;: [1, 2, np.nan, 4],<\/p>\n<p>    &#39;B&#39;: [np.nan, 2, 3, 4],<\/p>\n<p>    &#39;C&#39;: [1, 2, 3, pd.NA]<\/p>\n<p>})<\/p>\n<p>print(data_with_nan)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542bNaN\u548cPandas NA\u7684DataFrame\u3002Pandas\u4e2d\u7684NaN\u975e\u5e38\u9002\u5408\u5904\u7406\u8868\u683c\u6570\u636e\u4e2d\u7684\u7f3a\u5931\u503c\u3002<\/p>\n<\/p>\n<p><h3>2. Pandas\u4e2d\u7684NaN\u7684\u5904\u7406<\/h3>\n<\/p>\n<p><p>Pandas\u63d0\u4f9b\u4e86\u591a\u79cd\u5904\u7406NaN\u7684\u65b9\u6cd5\uff0c\u5305\u62ec\u68c0\u6d4b\u3001\u586b\u5145\u548c\u5220\u9664NaN\u503c\u3002\u5728Pandas\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>pandas.DataFrame.isna()<\/code> \u68c0\u6d4bNaN\uff0c\u5e76\u4f7f\u7528 <code>pandas.DataFrame.fillna()<\/code> \u586b\u5145NaN\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>data_with_nan = pd.DataFrame({<\/p>\n<p>    &#39;A&#39;: [1, 2, np.nan, 4],<\/p>\n<p>    &#39;B&#39;: [np.nan, 2, 3, 4],<\/p>\n<p>    &#39;C&#39;: [1, 2, 3, pd.NA]<\/p>\n<p>})<\/p>\n<h2><strong>\u68c0\u6d4bNaN<\/strong><\/h2>\n<p>nan_mask = data_with_nan.isna()<\/p>\n<p>print(&quot;NaN mask:\\n&quot;, nan_mask)<\/p>\n<h2><strong>\u586b\u5145NaN\u4e3a0<\/strong><\/h2>\n<p>data_filled = data_with_nan.fillna(0)<\/p>\n<p>print(&quot;Data with NaN filled:\\n&quot;, data_filled)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 <code>pandas.DataFrame.isna()<\/code> \u68c0\u6d4bDataFrame\u4e2d\u7684NaN\u4f4d\u7f6e\uff0c\u7136\u540e\u4f7f\u7528 <code>pandas.DataFrame.fillna()<\/code> \u5c06NaN\u66ff\u6362\u4e3a0\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001NAN\u7684\u5e94\u7528\u573a\u666f<\/p>\n<\/p>\n<p><p>NaN\u5728\u6570\u636e\u79d1\u5b66\u548c\u6570\u636e\u5206\u6790\u4e2d\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u65e0\u8bba\u662f\u5904\u7406\u6570\u503c\u6570\u636e\u8fd8\u662f\u6df7\u5408\u7c7b\u578b\u6570\u636e\uff0cNaN\u7684\u5e94\u7528\u90fd\u80fd\u5e2e\u52a9\u6211\u4eec\u66f4\u6709\u6548\u5730\u5904\u7406\u7f3a\u5931\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>1. \u6570\u636e\u6e05\u6d17<\/h3>\n<\/p>\n<p><p>\u5728\u6570\u636e\u79d1\u5b66\u4e2d\uff0c\u6570\u636e\u6e05\u6d17\u662f\u4e00\u4e2a\u81f3\u5173\u91cd\u8981\u7684\u6b65\u9aa4\u3002NaN\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u6807\u8bb0\u548c\u5904\u7406\u6570\u636e\u4e2d\u7684\u7f3a\u5931\u90e8\u5206\u3002\u901a\u8fc7\u4f7f\u7528NaN\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u68c0\u6d4b\u548c\u586b\u5145\u7f3a\u5931\u503c\uff0c\u4ece\u800c\u4f7f\u6570\u636e\u66f4\u5b8c\u6574\u548c\u4e00\u81f4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u793a\u4f8b\u6570\u636e<\/strong><\/h2>\n<p>data = pd.DataFrame({<\/p>\n<p>    &#39;Name&#39;: [&#39;Alice&#39;, &#39;Bob&#39;, None, &#39;David&#39;],<\/p>\n<p>    &#39;Age&#39;: [24, np.nan, 22, 29]<\/p>\n<p>})<\/p>\n<h2><strong>\u68c0\u6d4b\u7f3a\u5931\u6570\u636e<\/strong><\/h2>\n<p>missing_data_mask = data.isna()<\/p>\n<h2><strong>\u586b\u5145\u7f3a\u5931\u6570\u636e<\/strong><\/h2>\n<p>data_cleaned = data.fillna({&#39;Name&#39;: &#39;Unknown&#39;, &#39;Age&#39;: data[&#39;Age&#39;].mean()})<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u68c0\u6d4bDataFrame\u4e2d\u7684\u7f3a\u5931\u6570\u636e\uff0c\u7136\u540e\u7528\u4e00\u4e2a\u9ed8\u8ba4\u503c\u548c\u5747\u503c\u586b\u5145\u8fd9\u4e9b\u7f3a\u5931\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>2. \u6570\u636e\u5206\u6790\u548c\u5efa\u6a21<\/h3>\n<\/p>\n<p><p>\u5728\u6570\u636e\u5206\u6790\u548c\u5efa\u6a21\u4e2d\uff0cNaN\u4e5f\u8d77\u7740\u91cd\u8981\u7684\u4f5c\u7528\u3002NaN\u503c\u53ef\u4ee5\u7528\u6765\u8868\u793a\u6570\u636e\u96c6\u4e2d\u672a\u77e5\u6216\u4e0d\u53ef\u7528\u7684\u90e8\u5206\u3002\u5728\u8fdb\u884c\u6570\u636e\u5efa\u6a21\u65f6\uff0c\u5904\u7406NaN\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u6b65\u9aa4\uff0c\u56e0\u4e3a\u5927\u591a\u6570<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u6a21\u578b\u90fd\u4e0d\u80fd\u76f4\u63a5\u5904\u7406NaN\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>from sklearn.impute import SimpleImputer<\/p>\n<h2><strong>\u793a\u4f8b\u6570\u636e<\/strong><\/h2>\n<p>data = pd.DataFrame({<\/p>\n<p>    &#39;Feature1&#39;: [1, 2, np.nan, 4],<\/p>\n<p>    &#39;Feature2&#39;: [np.nan, 2, 3, 4]<\/p>\n<p>})<\/p>\n<h2><strong>\u4f7f\u7528SimpleImputer\u5904\u7406NaN<\/strong><\/h2>\n<p>imputer = SimpleImputer(strategy=&#39;mean&#39;)<\/p>\n<p>data_imputed = imputer.fit_transform(data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 <code>SimpleImputer<\/code> \u6765\u5904\u7406NaN\u503c\uff0c\u901a\u8fc7\u7528\u7279\u5f81\u7684\u5747\u503c\u66ff\u6362NaN\uff0c\u4ece\u800c\u4f7f\u6570\u636e\u96c6\u53ef\u4ee5\u7528\u4e8e\u673a\u5668\u5b66\u4e60\u6a21\u578b\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001NAN\u7684\u7279\u6b8a\u6027\u548c\u6ce8\u610f\u4e8b\u9879<\/p>\n<\/p>\n<p><p>\u867d\u7136NaN\u5728\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u4e2d\u975e\u5e38\u6709\u7528\uff0c\u4f46\u5b83\u4e5f\u5e26\u6765\u4e86\u4e00\u4e9b\u7279\u6b8a\u6027\u548c\u6ce8\u610f\u4e8b\u9879\u3002\u4e86\u89e3\u8fd9\u4e9b\u7279\u6027\u6709\u52a9\u4e8e\u6211\u4eec\u66f4\u597d\u5730\u4f7f\u7528NaN\u3002<\/p>\n<\/p>\n<p><h3>1. NaN\u4e0eNaN\u7684\u6bd4\u8f83<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0cNaN\u4e0eNaN\u7684\u6bd4\u8f83\u662f\u4e0d\u76f8\u7b49\u7684\u3002\u8fd9\u662f\u56e0\u4e3aNaN\u8868\u793a\u4e00\u4e2a\u672a\u77e5\u7684\u6570\u503c\uff0c\u56e0\u6b64\u4e24\u4e2aNaN\u503c\u4e0d\u80fd\u88ab\u8ba4\u4e3a\u662f\u76f8\u540c\u7684\u3002\u8fd9\u4e00\u70b9\u5728\u5904\u7406\u6570\u636e\u65f6\u9700\u8981\u7279\u522b\u6ce8\u610f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>nan1 = np.nan<\/p>\n<p>nan2 = np.nan<\/p>\n<h2><strong>\u6bd4\u8f83NaN<\/strong><\/h2>\n<p>print(nan1 == nan2)  # \u8f93\u51fa: False<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7531\u4e8eNaN\u4e0eNaN\u4e0d\u76f8\u7b49\uff0c\u5728\u6570\u636e\u5904\u7406\u4e2d\u9700\u8981\u5c0f\u5fc3\uff0c\u7279\u522b\u662f\u5728\u8fdb\u884c\u6761\u4ef6\u5224\u65ad\u548c\u6570\u636e\u8fc7\u6ee4\u65f6\u3002<\/p>\n<\/p>\n<p><h3>2. NaN\u4e0e\u5176\u4ed6\u6570\u503c\u7684\u8fd0\u7b97<\/h3>\n<\/p>\n<p><p>NaN\u5728\u4e0e\u5176\u4ed6\u6570\u503c\u8fdb\u884c\u8fd0\u7b97\u65f6\uff0c\u7ed3\u679c\u901a\u5e38\u4e5f\u662fNaN\u3002\u8fd9\u662f\u56e0\u4e3a\u4efb\u4f55\u6570\u503c\u4e0e\u672a\u77e5\u7684\u6570\u503c\u8fdb\u884c\u8fd0\u7b97\uff0c\u5176\u7ed3\u679c\u4e5f\u662f\u672a\u77e5\u7684\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>value = 10<\/p>\n<p>nan_value = np.nan<\/p>\n<h2><strong>\u4e0eNaN\u8fdb\u884c\u8fd0\u7b97<\/strong><\/h2>\n<p>result = value + nan_value<\/p>\n<p>print(result)  # \u8f93\u51fa: nan<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u6570\u636e\u5206\u6790\u4e2d\u8fdb\u884c\u6570\u503c\u8fd0\u7b97\u65f6\uff0c\u9700\u8981\u6ce8\u610fNaN\u5e26\u6765\u7684\u8fd9\u79cd\u7279\u6027\uff0c\u5e76\u5728\u5fc5\u8981\u65f6\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001NAN\u5728\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u4e2d\u7684\u8868\u73b0<\/p>\n<\/p>\n<p><p>NaN\u5728\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u4e2d\u7684\u8868\u73b0\u5404\u5f02\u3002\u4e86\u89e3\u8fd9\u4e9b\u5dee\u5f02\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5728\u6570\u636e\u5904\u7406\u65f6\u66f4\u7075\u6d3b\u5730\u5e94\u5bf9\u5404\u79cd\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><h3>1. \u6570\u503c\u578b\u6570\u636e\u4e2d\u7684NaN<\/h3>\n<\/p>\n<p><p>\u5728\u6570\u503c\u578b\u6570\u636e\u4e2d\uff0cNaN\u901a\u5e38\u7528\u4e8e\u8868\u793a\u7f3a\u5931\u7684\u6d6e\u70b9\u6570\u3002\u5728\u5904\u7406\u6570\u503c\u578b\u6570\u636e\u65f6\uff0cNumPy\u7684 <code>numpy.nan<\/code> \u662f\u4e00\u4e2a\u5e38\u7528\u7684\u9009\u62e9\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u6570\u503c\u578b\u6570\u636e\u4e2d\u7684NaN<\/strong><\/h2>\n<p>numeric_data = np.array([1.0, 2.0, np.nan, 4.0])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u7528NaN\u8868\u793a\u4e00\u4e2a\u7f3a\u5931\u7684\u6d6e\u70b9\u6570\u503c\u3002<\/p>\n<\/p>\n<p><h3>2. \u975e\u6570\u503c\u578b\u6570\u636e\u4e2d\u7684NaN<\/h3>\n<\/p>\n<p><p>\u5728\u975e\u6570\u503c\u578b\u6570\u636e\u4e2d\uff0c\u5982\u5b57\u7b26\u4e32\u6216\u5bf9\u8c61\u6570\u636e\uff0cPandas\u7684 <code>pandas.NA<\/code> \u662f\u4e00\u4e2a\u66f4\u5408\u9002\u7684\u9009\u62e9\u3002\u5b83\u53ef\u4ee5\u8868\u793a\u5404\u79cd\u7c7b\u578b\u6570\u636e\u4e2d\u7684\u7f3a\u5931\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u975e\u6570\u503c\u578b\u6570\u636e\u4e2d\u7684NaN<\/strong><\/h2>\n<p>data = pd.Series([&#39;apple&#39;, &#39;banana&#39;, pd.NA, &#39;cherry&#39;])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u7528Pandas\u7684 <code>pd.NA<\/code> \u8868\u793a\u5b57\u7b26\u4e32\u6570\u636e\u4e2d\u7684\u7f3a\u5931\u503c\u3002<\/p>\n<\/p>\n<p><p>\u516d\u3001NAN\u7684\u66ff\u4ee3\u7b56\u7565<\/p>\n<\/p>\n<p><p>\u5728\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u8fc7\u7a0b\u4e2d\uff0c\u66ff\u4ee3NaN\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u4efb\u52a1\u3002\u6709\u591a\u79cd\u7b56\u7565\u53ef\u4ee5\u7528\u6765\u66ff\u4ee3NaN\uff0c\u5177\u4f53\u9009\u62e9\u53d6\u51b3\u4e8e\u6570\u636e\u7684\u7279\u6027\u548c\u5206\u6790\u7684\u76ee\u6807\u3002<\/p>\n<\/p>\n<p><h3>1. \u5747\u503c\u66ff\u4ee3<\/h3>\n<\/p>\n<p><p>\u5747\u503c\u66ff\u4ee3\u662f\u4e00\u79cd\u7b80\u5355\u800c\u5e38\u7528\u7684\u7b56\u7565\uff0c\u7279\u522b\u9002\u7528\u4e8e\u6570\u503c\u578b\u6570\u636e\u3002\u901a\u8fc7\u7528\u6570\u636e\u7684\u5747\u503c\u66ff\u4ee3NaN\uff0c\u6211\u4eec\u53ef\u4ee5\u4fdd\u6301\u6570\u636e\u7684\u6574\u4f53\u7279\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>import numpy as np<\/p>\n<p>data = pd.Series([1, 2, np.nan, 4, 5])<\/p>\n<h2><strong>\u4f7f\u7528\u5747\u503c\u66ff\u4ee3NaN<\/strong><\/h2>\n<p>mean_value = data.mean()<\/p>\n<p>data_filled = data.fillna(mean_value)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u8ba1\u7b97\u4e86\u6570\u636e\u7684\u5747\u503c\uff0c\u5e76\u7528\u5b83\u66ff\u4ee3NaN\u3002<\/p>\n<\/p>\n<p><h3>2. \u63d2\u503c\u6cd5<\/h3>\n<\/p>\n<p><p>\u63d2\u503c\u6cd5\u662f\u4e00\u79cd\u66f4\u590d\u6742\u7684\u66ff\u4ee3\u7b56\u7565\uff0c\u9002\u7528\u4e8e\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u6216\u6709\u5e8f\u6570\u636e\u3002\u901a\u8fc7\u63d2\u503c\uff0c\u6211\u4eec\u53ef\u4ee5\u5229\u7528\u6570\u636e\u7684\u8d8b\u52bf\u548c\u6a21\u5f0f\u6765\u586b\u5145NaN\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>data = pd.Series([1, 2, np.nan, 4, 5])<\/p>\n<h2><strong>\u4f7f\u7528\u63d2\u503c\u6cd5\u66ff\u4ee3NaN<\/strong><\/h2>\n<p>data_interpolated = data.interpolate()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u63d2\u503c\u6cd5\u66ff\u4ee3\u4e86\u6570\u636e\u4e2d\u7684NaN\u3002\u63d2\u503c\u6cd5\u5728\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u65f6\u7279\u522b\u6709\u7528\u3002<\/p>\n<\/p>\n<p><p>\u4e03\u3001NAN\u5904\u7406\u4e2d\u7684\u5e38\u89c1\u6311\u6218<\/p>\n<\/p>\n<p><p>\u5728\u5904\u7406NaN\u65f6\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u6311\u6218\u3002\u8fd9\u4e9b\u6311\u6218\u5305\u62ec\u5982\u4f55\u5728\u590d\u6742\u7684\u6570\u636e\u96c6\u4e2d\u6709\u6548\u5730\u68c0\u6d4b\u548c\u66ff\u4ee3NaN\uff0c\u4ee5\u53ca\u5982\u4f55\u5728\u4e0d\u5931\u53bb\u6570\u636e\u5b8c\u6574\u6027\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u8fd9\u4e9b\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h3>1. \u5927\u6570\u636e\u96c6\u4e2d\u7684NaN\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u5728\u5927\u6570\u636e\u96c6\u4e2d\uff0cNaN\u7684\u5b58\u5728\u53ef\u80fd\u4f1a\u5bf9\u8ba1\u7b97\u6027\u80fd\u4ea7\u751f\u5f71\u54cd\u3002\u4e3a\u4e86\u6709\u6548\u5730\u5904\u7406\u5927\u6570\u636e\u96c6\u4e2d\u7684NaN\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528\u9ad8\u6548\u7684\u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u4f7f\u7528NumPy\u548cPandas\u7684\u9ad8\u6548\u64cd\u4f5c\uff0c\u80fd\u591f\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u65f6\u4fdd\u6301\u826f\u597d\u7684\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>import numpy as np<\/p>\n<h2><strong>\u5927\u6570\u636e\u96c6\u793a\u4f8b<\/strong><\/h2>\n<p>large_data = pd.DataFrame(np.random.rand(1000000, 10))<\/p>\n<p>large_data.iloc[0, 0] = np.nan  # \u5f15\u5165\u4e00\u4e2aNaN<\/p>\n<h2><strong>\u9ad8\u6548\u68c0\u6d4b\u548c\u5904\u7406NaN<\/strong><\/h2>\n<p>nan_mask = large_data.isna()<\/p>\n<p>large_data_filled = large_data.fillna(large_data.mean())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5904\u7406\u4e86\u4e00\u4e2a\u5927\u6570\u636e\u96c6\u4e2d\u7684NaN\uff0c\u5e76\u4fdd\u6301\u4e86\u826f\u597d\u7684\u8ba1\u7b97\u6548\u7387\u3002<\/p>\n<\/p>\n<p><h3>2. \u591a\u7c7b\u578b\u6570\u636e\u4e2d\u7684NaN\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u5728\u5305\u542b\u591a\u79cd\u6570\u636e\u7c7b\u578b\u7684\u6570\u636e\u96c6\u4e2d\uff0c\u5904\u7406NaN\u53ef\u80fd\u4f1a\u53d8\u5f97\u66f4\u52a0\u590d\u6742\u3002\u6211\u4eec\u9700\u8981\u6839\u636e\u6570\u636e\u7c7b\u578b\u7684\u4e0d\u540c\uff0c\u9009\u62e9\u5408\u9002\u7684NaN\u8868\u793a\u548c\u5904\u7406\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>import numpy as np<\/p>\n<h2><strong>\u591a\u7c7b\u578b\u6570\u636e\u96c6\u793a\u4f8b<\/strong><\/h2>\n<p>mixed_data = pd.DataFrame({<\/p>\n<p>    &#39;Numeric&#39;: [1.0, 2.0, np.nan, 4.0],<\/p>\n<p>    &#39;Categorical&#39;: [&#39;cat&#39;, &#39;dog&#39;, pd.NA, &#39;mouse&#39;]<\/p>\n<p>})<\/p>\n<h2><strong>\u5206\u522b\u5904\u7406\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e<\/strong><\/h2>\n<p>numeric_filled = mixed_data[&#39;Numeric&#39;].fillna(mixed_data[&#39;Numeric&#39;].mean())<\/p>\n<p>categorical_filled = mixed_data[&#39;Categorical&#39;].fillna(&#39;unknown&#39;)<\/p>\n<p>mixed_data_filled = pd.DataFrame({<\/p>\n<p>    &#39;Numeric&#39;: numeric_filled,<\/p>\n<p>    &#39;Categorical&#39;: categorical_filled<\/p>\n<p>})<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5206\u522b\u5904\u7406\u4e86\u6570\u503c\u548c\u5206\u7c7b\u6570\u636e\u4e2d\u7684NaN\uff0c\u9009\u62e9\u4e86\u9002\u5408\u6bcf\u79cd\u7c7b\u578b\u7684\u66ff\u4ee3\u7b56\u7565\u3002<\/p>\n<\/p>\n<p><p>\u516b\u3001NAN\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u91cd\u8981\u6027<\/p>\n<\/p>\n<p><p>\u5728\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u5904\u7406NaN\u662f\u6570\u636e\u9884\u5904\u7406\u7684\u5173\u952e\u6b65\u9aa4\u4e4b\u4e00\u3002NaN\u7684\u5b58\u5728\u53ef\u80fd\u4f1a\u5f71\u54cd\u6a21\u578b\u7684\u8bad\u7ec3\u548c\u9884\u6d4b\uff0c\u56e0\u6b64\u5728\u6570\u636e\u9884\u5904\u7406\u9636\u6bb5\uff0c\u9700\u8981\u8c28\u614e\u5904\u7406NaN\u3002<\/p>\n<\/p>\n<p><h3>1. \u6a21\u578b\u8bad\u7ec3\u524d\u7684NaN\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u5728\u6a21\u578b\u8bad\u7ec3\u524d\uff0c\u5904\u7406NaN\u662f\u4fdd\u8bc1\u6a21\u578b\u6027\u80fd\u7684\u57fa\u7840\u3002\u5927\u591a\u6570\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u4e0d\u80fd\u76f4\u63a5\u5904\u7406NaN\uff0c\u56e0\u6b64\u9700\u8981\u5728\u8bad\u7ec3\u524d\u8fdb\u884c\u66ff\u4ee3\u6216\u5220\u9664\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>from sklearn.impute import SimpleImputer<\/p>\n<p>from sklearn.linear_model import LinearRegression<\/p>\n<h2><strong>\u793a\u4f8b\u6570\u636e<\/strong><\/h2>\n<p>data = pd.DataFrame({<\/p>\n<p>    &#39;Feature1&#39;: [1, 2, np.nan, 4],<\/p>\n<p>    &#39;Feature2&#39;: [np.nan, 2, 3, 4],<\/p>\n<p>    &#39;Target&#39;: [1, 2, 1, 2]<\/p>\n<p>})<\/p>\n<h2><strong>\u4f7f\u7528SimpleImputer\u5904\u7406NaN<\/strong><\/h2>\n<p>imputer = SimpleImputer(strategy=&#39;mean&#39;)<\/p>\n<p>features = data[[&#39;Feature1&#39;, &#39;Feature2&#39;]]<\/p>\n<p>features_imputed = imputer.fit_transform(features)<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>model = LinearRegression()<\/p>\n<p>model.fit(features_imputed, data[&#39;Target&#39;])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5728\u6a21\u578b\u8bad\u7ec3\u524d\u4f7f\u7528 <code>SimpleImputer<\/code> \u66ff\u4ee3\u4e86\u6570\u636e\u4e2d\u7684NaN\uff0c\u786e\u4fdd\u6a21\u578b\u80fd\u591f\u987a\u5229\u8bad\u7ec3\u3002<\/p>\n<\/p>\n<p><h3>2. NaN\u5728\u9884\u6d4b\u4e2d\u7684\u5f71\u54cd<\/h3>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u9884\u6d4b\u65f6\uff0cNaN\u7684\u5b58\u5728\u4e5f\u4f1a\u5f71\u54cd\u9884\u6d4b\u7ed3\u679c\u3002\u5904\u7406NaN\u4e0d\u4ec5\u4ec5\u662f\u5728\u8bad\u7ec3\u524d\u8fdb\u884c\uff0c\u5bf9\u4e8e\u65b0\u6570\u636e\u4e2d\u7684NaN\uff0c\u6211\u4eec\u4e5f\u9700\u8981\u8fdb\u884c\u76f8\u5e94\u7684\u5904\u7406\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u65b0\u6570\u636e<\/strong><\/h2>\n<p>new_data = np.array([[2, np.nan], [3, 4]])<\/p>\n<h2><strong>\u4f7f\u7528\u8bad\u7ec3\u65f6\u7684\u7b56\u7565\u5904\u7406NaN<\/strong><\/h2>\n<p>new_data_imputed = imputer.transform(new_data)<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>predictions = model.predict(new_data_imputed)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5728\u8fdb\u884c\u9884\u6d4b\u524d\u5bf9\u65b0\u6570\u636e\u4e2d\u7684NaN\u8fdb\u884c\u4e86\u66ff\u4ee3\uff0c\u786e\u4fdd\u9884\u6d4b\u7ed3\u679c\u7684\u51c6\u786e\u6027\u3002<\/p>\n<\/p>\n<p><p>\u603b\u7ed3\u6765\u8bf4\uff0cNaN\u5728Python\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u4e2d\u626e\u6f14\u7740\u91cd\u8981\u7684\u89d2\u8272\u3002\u4e86\u89e3\u548c\u638c\u63e1NaN\u7684\u4f7f\u7528\u548c\u5904\u7406\u65b9\u6cd5\uff0c\u5c06\u6781\u5927\u63d0\u5347\u6211\u4eec\u5728\u6570\u636e\u79d1\u5b66\u548c\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u5de5\u4f5c\u6548\u7387\u548c\u6548\u679c\u3002\u901a\u8fc7NumPy\u548cPandas\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u521b\u5efa\u3001\u68c0\u6d4b\u548c\u5904\u7406NaN\u503c\uff0c\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u4e00\u81f4\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u521b\u5efa\u4e00\u4e2aNaN\u503c\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u521b\u5efaNaN\u503c\u3002\u5177\u4f53\u65b9\u6cd5\u662f\u4f7f\u7528<code>numpy.nan<\/code>\uff0c\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">import numpy as np\nnan_value = np.nan\nprint(nan_value)  # \u8f93\u51fa: nan\n<\/code><\/pre>\n<p>\u6b64\u5916\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528Pandas\u5e93\u4e2d\u7684<code>pd.NA<\/code>\u6216<code>pd.NaT<\/code>\uff0c\u8fd9\u5bf9\u4e8e\u5904\u7406\u7f3a\u5931\u6570\u636e\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n<p><strong>\u5728\u5904\u7406\u6570\u636e\u65f6\uff0c\u5982\u4f55\u68c0\u6d4bNaN\u503c\uff1f<\/strong><br \/>\u53ef\u4ee5\u4f7f\u7528NumPy\u7684<code>numpy.isnan()<\/code>\u51fd\u6570\u6216Pandas\u7684<code>isna()<\/code>\u65b9\u6cd5\u6765\u68c0\u6d4bNaN\u503c\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">import numpy as np\ndata = [1, 2, np.nan, 4]\nnan_check = np.isnan(data)  # \u8f93\u51fa: [False False  True False]\n<\/code><\/pre>\n<p>\u5728Pandas\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a  <\/p>\n<pre><code class=\"language-python\">import pandas as pd\nseries = pd.Series([1, 2, None, 4])\nnan_check = series.isna()  # \u8f93\u51fa: [False False  True False]\n<\/code><\/pre>\n<p><strong>\u5982\u4f55\u5728\u6570\u636e\u5206\u6790\u4e2d\u5904\u7406NaN\u503c\uff1f<\/strong><br \/>\u5904\u7406NaN\u503c\u7684\u65b9\u6cd5\u591a\u79cd\u591a\u6837\uff0c\u5e38\u89c1\u7684\u6709\u5220\u9664\u3001\u586b\u5145\u6216\u66ff\u6362\u3002\u4f7f\u7528Pandas\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>dropna()<\/code>\u5220\u9664\u5305\u542bNaN\u7684\u884c\uff0c\u6216\u4f7f\u7528<code>fillna()<\/code>\u8fdb\u884c\u586b\u5145\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\"># \u5220\u9664\u5305\u542bNaN\u7684\u884c\ncleaned_data = series.dropna()\n\n# \u4f7f\u7528\u7279\u5b9a\u503c\u586b\u5145NaN\nfilled_data = series.fillna(0)  # \u4f7f\u75280\u586b\u5145NaN\n<\/code><\/pre>\n<p>\u9009\u62e9\u5408\u9002\u7684\u5904\u7406\u65b9\u6cd5\u53d6\u51b3\u4e8e\u6570\u636e\u5206\u6790\u7684\u5177\u4f53\u9700\u6c42\u548c\u4e0a\u4e0b\u6587\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7NumPy\u5e93\u6216Pandas\u5e93\u6765\u6253\u51faNaN\u3002NumPy\u7684 numpy.nan \u548c Pa [&hellip;]","protected":false},"author":3,"featured_media":1017530,"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\/1017492"}],"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=1017492"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1017492\/revisions"}],"predecessor-version":[{"id":1017538,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1017492\/revisions\/1017538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1017530"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1017492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1017492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1017492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}