{"id":1072060,"date":"2025-01-08T11:12:49","date_gmt":"2025-01-08T03:12:49","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1072060.html"},"modified":"2025-01-08T11:12:52","modified_gmt":"2025-01-08T03:12:52","slug":"python%e4%b8%ad%e7%9a%84pandas%e5%a6%82%e4%bd%95%e5%88%a0%e9%99%a4%e6%9f%90%e5%88%97-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1072060.html","title":{"rendered":"python\u4e2d\u7684pandas\u5982\u4f55\u5220\u9664\u67d0\u5217"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25102405\/6825c26f-ff15-4fa3-bee4-78337483b70f.webp\" alt=\"python\u4e2d\u7684pandas\u5982\u4f55\u5220\u9664\u67d0\u5217\" \/><\/p>\n<p><p> <strong>\u5728Python\u7684Pandas\u5e93\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>drop<\/code>\u65b9\u6cd5\u5220\u9664\u67d0\u5217\u3001\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5217\u540d\u7684\u65b9\u5f0f\u4f7f\u7528<code>del<\/code>\u5173\u952e\u5b57\u6765\u5220\u9664\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u5728Pandas\u4e2d\u5220\u9664\u67d0\u5217\u6570\u636e\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u8981\u5220\u9664\u7279\u5b9a\u7684\u5217\uff0c\u53ef\u4ee5\u4f7f\u7528<code>drop<\/code>\u65b9\u6cd5\u5e76\u6307\u5b9a\u5217\u540d\u3002\u8fd9\u4e2a\u65b9\u6cd5\u6709\u4e24\u4e2a\u91cd\u8981\u7684\u53c2\u6570\uff1a<code>axis<\/code>\u548c<code>inplace<\/code>\u3002\u5176\u4e2d\uff0c<code>axis=1<\/code>\u8868\u793a\u5220\u9664\u5217\uff08\u800c\u4e0d\u662f\u884c\uff09\uff0c<code>inplace=True<\/code>\u8868\u793a\u5728\u539fDataFrame\u4e0a\u8fdb\u884c\u4fee\u6539\u800c\u4e0d\u662f\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684DataFrame\u3002\u53e6\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528<code>del<\/code>\u5173\u952e\u5b57\u6765\u5220\u9664\u5217\u3002<\/p>\n<\/p>\n<p><h3>\u4f7f\u7528<code>drop<\/code>\u65b9\u6cd5\u5220\u9664\u67d0\u5217<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u793a\u4f8bDataFrame<\/strong><\/h2>\n<p>data = {&#39;A&#39;: [1, 2, 3], &#39;B&#39;: [4, 5, 6], &#39;C&#39;: [7, 8, 9]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u5220\u9664\u5217 &#39;B&#39;<\/strong><\/h2>\n<p>df.drop(&#39;B&#39;, axis=1, inplace=True)<\/p>\n<p>print(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4f7f\u7528<code>del<\/code>\u5173\u952e\u5b57\u5220\u9664\u67d0\u5217<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u793a\u4f8bDataFrame<\/strong><\/h2>\n<p>data = {&#39;A&#39;: [1, 2, 3], &#39;B&#39;: [4, 5, 6], &#39;C&#39;: [7, 8, 9]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u5220\u9664\u5217 &#39;B&#39;<\/strong><\/h2>\n<p>del df[&#39;B&#39;]<\/p>\n<p>print(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<hr>\n<p><h3>\u4e00\u3001PANDAS\u5e93\u4ecb\u7ecd<\/h3>\n<\/p>\n<p><p>Pandas\u662fPython\u4e2d\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u5e93\u3002\u5b83\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u6570\u636e\u7ed3\u6784\u548c\u6570\u636e\u5206\u6790\u5de5\u5177\uff0c\u4f7f\u5f97\u6570\u636e\u6e05\u6d17\u3001\u51c6\u5907\u548c\u5206\u6790\u53d8\u5f97\u7b80\u5355\u800c\u9ad8\u6548\u3002Pandas\u4e3b\u8981\u63d0\u4f9b\u4e86\u4e24\u79cd\u6570\u636e\u7ed3\u6784\uff1aSeries\uff08\u5e8f\u5217\uff09\u548cDataFrame\uff08\u6570\u636e\u5e27\uff09\uff0c\u5176\u4e2dDataFrame\u662f\u6700\u5e38\u7528\u7684\u6570\u636e\u7ed3\u6784\uff0c\u53ef\u4ee5\u770b\u4f5c\u662f\u4e00\u4e2a\u4e8c\u7ef4\u7684\u8868\u683c\u3002<\/p>\n<\/p>\n<p><h4>1.1 DataFrame\u7684\u6570\u636e\u7ed3\u6784<\/h4>\n<\/p>\n<p><p>DataFrame\u662fPandas\u4e2d\u6700\u5e38\u7528\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5b83\u7c7b\u4f3c\u4e8e\u4e00\u4e2aExcel\u8868\u683c\u6216\u8005\u6570\u636e\u5e93\u4e2d\u7684\u8868\uff0c\u662f\u4e00\u79cd\u4e8c\u7ef4\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5305\u542b\u884c\u548c\u5217\u3002\u6bcf\u4e00\u5217\u53ef\u4ee5\u662f\u4e0d\u540c\u7684\u6570\u636e\u7c7b\u578b\uff08\u6570\u503c\u3001\u5b57\u7b26\u4e32\u3001\u5e03\u5c14\u503c\u7b49\uff09\u3002DataFrame\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u65b9\u4fbf\u7684\u6570\u636e\u64cd\u4f5c\u65b9\u6cd5\uff0c\u4f7f\u5f97\u6570\u636e\u7684\u8bfb\u53d6\u3001\u6e05\u6d17\u3001\u5904\u7406\u548c\u5206\u6790\u53d8\u5f97\u7b80\u5355\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u793a\u4f8bDataFrame<\/strong><\/h2>\n<p>data = {&#39;A&#39;: [1, 2, 3], &#39;B&#39;: [4, 5, 6], &#39;C&#39;: [7, 8, 9]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<p>print(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\uff1a<\/p>\n<\/p>\n<p><pre><code>   A  B  C<\/p>\n<p>0  1  4  7<\/p>\n<p>1  2  5  8<\/p>\n<p>2  3  6  9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>1.2 \u6570\u636e\u6e05\u6d17\u548c\u5904\u7406<\/h4>\n<\/p>\n<p><p>\u5728\u6570\u636e\u5206\u6790\u8fc7\u7a0b\u4e2d\uff0c\u6570\u636e\u6e05\u6d17\u548c\u5904\u7406\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6b65\u9aa4\u3002Pandas\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6570\u636e\u6e05\u6d17\u548c\u5904\u7406\u529f\u80fd\uff0c\u5305\u62ec\u5904\u7406\u7f3a\u5931\u503c\u3001\u6570\u636e\u8f6c\u6362\u3001\u5220\u9664\u91cd\u590d\u6570\u636e\u3001\u6570\u636e\u7b5b\u9009\u548c\u6392\u5e8f\u7b49\u3002\u901a\u8fc7\u8fd9\u4e9b\u529f\u80fd\uff0c\u53ef\u4ee5\u5c06\u539f\u59cb\u6570\u636e\u8f6c\u5316\u4e3a\u5e72\u51c0\u3001\u89c4\u8303\u548c\u6613\u4e8e\u5206\u6790\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u7f3a\u5931\u503c\u7684\u793a\u4f8bDataFrame<\/strong><\/h2>\n<p>data = {&#39;A&#39;: [1, 2, None], &#39;B&#39;: [4, None, 6], &#39;C&#39;: [7, 8, 9]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u5904\u7406\u7f3a\u5931\u503c<\/strong><\/h2>\n<p>df.fillna(0, inplace=True)<\/p>\n<p>print(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\uff1a<\/p>\n<\/p>\n<p><pre><code>     A    B  C<\/p>\n<p>0  1.0  4.0  7<\/p>\n<p>1  2.0  0.0  8<\/p>\n<p>2  0.0  6.0  9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528<code>drop<\/code>\u65b9\u6cd5\u5220\u9664\u5217<\/h3>\n<\/p>\n<p><p><code>drop<\/code>\u65b9\u6cd5\u662fPandas\u4e2d\u7528\u4e8e\u5220\u9664\u884c\u6216\u5217\u7684\u4e3b\u8981\u65b9\u6cd5\u3002\u901a\u8fc7\u6307\u5b9a<code>axis<\/code>\u53c2\u6570\uff0c\u53ef\u4ee5\u9009\u62e9\u5220\u9664\u884c\u8fd8\u662f\u5217\u3002<code>axis=0<\/code>\u8868\u793a\u5220\u9664\u884c\uff0c<code>axis=1<\/code>\u8868\u793a\u5220\u9664\u5217\u3002<code>inplace<\/code>\u53c2\u6570\u7528\u4e8e\u6307\u5b9a\u662f\u5426\u76f4\u63a5\u5728\u539fDataFrame\u4e0a\u8fdb\u884c\u4fee\u6539\uff0c<code>inplace=True<\/code>\u8868\u793a\u5728\u539fDataFrame\u4e0a\u8fdb\u884c\u4fee\u6539\uff0c<code>inplace=False<\/code>\uff08\u9ed8\u8ba4\u503c\uff09\u8868\u793a\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684DataFrame\u3002<\/p>\n<\/p>\n<p><h4>2.1 \u5220\u9664\u5355\u5217<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u793a\u4f8bDataFrame<\/strong><\/h2>\n<p>data = {&#39;A&#39;: [1, 2, 3], &#39;B&#39;: [4, 5, 6], &#39;C&#39;: [7, 8, 9]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u5220\u9664\u5217 &#39;B&#39;<\/strong><\/h2>\n<p>df.drop(&#39;B&#39;, axis=1, inplace=True)<\/p>\n<p>print(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\uff1a<\/p>\n<\/p>\n<p><pre><code>   A  C<\/p>\n<p>0  1  7<\/p>\n<p>1  2  8<\/p>\n<p>2  3  9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u4f7f\u7528<code>drop<\/code>\u65b9\u6cd5\u5220\u9664\u4e86\u5217<code>B<\/code>\uff0c\u5e76\u901a\u8fc7<code>inplace=True<\/code>\u53c2\u6570\u5728\u539fDataFrame\u4e0a\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<\/p>\n<p><h4>2.2 \u5220\u9664\u591a\u5217<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u901a\u8fc7\u4f20\u9012\u4e00\u4e2a\u5217\u540d\u5217\u8868\u6765\u5220\u9664\u591a\u5217\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u793a\u4f8bDataFrame<\/strong><\/h2>\n<p>data = {&#39;A&#39;: [1, 2, 3], &#39;B&#39;: [4, 5, 6], &#39;C&#39;: [7, 8, 9]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u5220\u9664\u5217 &#39;B&#39; \u548c &#39;C&#39;<\/strong><\/h2>\n<p>df.drop([&#39;B&#39;, &#39;C&#39;], axis=1, inplace=True)<\/p>\n<p>print(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\uff1a<\/p>\n<\/p>\n<p><pre><code>   A<\/p>\n<p>0  1<\/p>\n<p>1  2<\/p>\n<p>2  3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.3 \u5220\u9664\u5217\u5e76\u8fd4\u56de\u65b0DataFrame<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u4e0d\u60f3\u5728\u539fDataFrame\u4e0a\u8fdb\u884c\u4fee\u6539\uff0c\u53ef\u4ee5\u5c06<code>inplace<\/code>\u53c2\u6570\u8bbe\u7f6e\u4e3a<code>False<\/code>\uff08\u9ed8\u8ba4\u503c\uff09\uff0c\u8fd9\u6837<code>drop<\/code>\u65b9\u6cd5\u4f1a\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684DataFrame\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u793a\u4f8bDataFrame<\/strong><\/h2>\n<p>data = {&#39;A&#39;: [1, 2, 3], &#39;B&#39;: [4, 5, 6], &#39;C&#39;: [7, 8, 9]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u5220\u9664\u5217 &#39;B&#39; \u5e76\u8fd4\u56de\u65b0DataFrame<\/strong><\/h2>\n<p>new_df = df.drop(&#39;B&#39;, axis=1)<\/p>\n<p>print(new_df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\uff1a<\/p>\n<\/p>\n<p><pre><code>   A  C<\/p>\n<p>0  1  7<\/p>\n<p>1  2  8<\/p>\n<p>2  3  9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u539fDataFrame <code>df<\/code>\u4e0d\u4f1a\u53d7\u5230\u5f71\u54cd\uff0c\u65b0\u7684DataFrame <code>new_df<\/code>\u5220\u9664\u4e86\u5217<code>B<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528<code>del<\/code>\u5173\u952e\u5b57\u5220\u9664\u5217<\/h3>\n<\/p>\n<p><p>\u9664\u4e86<code>drop<\/code>\u65b9\u6cd5\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528<code>del<\/code>\u5173\u952e\u5b57\u5220\u9664\u5217\u3002\u8fd9\u79cd\u65b9\u6cd5\u66f4\u52a0\u7b80\u6d01\uff0c\u4f46\u53ea\u80fd\u5728\u539fDataFrame\u4e0a\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<\/p>\n<p><h4>3.1 \u5220\u9664\u5355\u5217<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u793a\u4f8bDataFrame<\/strong><\/h2>\n<p>data = {&#39;A&#39;: [1, 2, 3], &#39;B&#39;: [4, 5, 6], &#39;C&#39;: [7, 8, 9]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u5220\u9664\u5217 &#39;B&#39;<\/strong><\/h2>\n<p>del df[&#39;B&#39;]<\/p>\n<p>print(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\uff1a<\/p>\n<\/p>\n<p><pre><code>   A  C<\/p>\n<p>0  1  7<\/p>\n<p>1  2  8<\/p>\n<p>2  3  9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.2 \u5220\u9664\u591a\u5217<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u5220\u9664\u591a\u5217\uff0c\u53ef\u4ee5\u4f7f\u7528<code>del<\/code>\u5173\u952e\u5b57\u9010\u4e2a\u5220\u9664\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u793a\u4f8bDataFrame<\/strong><\/h2>\n<p>data = {&#39;A&#39;: [1, 2, 3], &#39;B&#39;: [4, 5, 6], &#39;C&#39;: [7, 8, 9]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u5220\u9664\u5217 &#39;B&#39; \u548c &#39;C&#39;<\/strong><\/h2>\n<p>del df[&#39;B&#39;]<\/p>\n<p>del df[&#39;C&#39;]<\/p>\n<p>print(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\uff1a<\/p>\n<\/p>\n<p><pre><code>   A<\/p>\n<p>0  1<\/p>\n<p>1  2<\/p>\n<p>2  3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728Python\u7684Pandas\u5e93\u4e2d\u5220\u9664\u67d0\u5217\u6570\u636e\u3002\u53ef\u4ee5\u4f7f\u7528<code>drop<\/code>\u65b9\u6cd5\u6216\u8005<code>del<\/code>\u5173\u952e\u5b57\u6765\u5220\u9664\u5217\u3002\u4f7f\u7528<code>drop<\/code>\u65b9\u6cd5\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e<code>axis<\/code>\u548c<code>inplace<\/code>\u53c2\u6570\u6765\u63a7\u5236\u5220\u9664\u7684\u884c\u4e3a\uff0c<code>axis=1<\/code>\u8868\u793a\u5220\u9664\u5217\uff0c<code>inplace=True<\/code>\u8868\u793a\u5728\u539fDataFrame\u4e0a\u8fdb\u884c\u4fee\u6539\u3002\u4f7f\u7528<code>del<\/code>\u5173\u952e\u5b57\u65f6\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u539fDataFrame\u4e0a\u5220\u9664\u5217\u3002\u65e0\u8bba\u662f\u4f7f\u7528<code>drop<\/code>\u65b9\u6cd5\u8fd8\u662f<code>del<\/code>\u5173\u952e\u5b57\uff0c\u5220\u9664\u5217\u64cd\u4f5c\u90fd\u975e\u5e38\u7b80\u5355\u65b9\u4fbf\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u5b66\u4e60\u548c\u638c\u63e1\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u52a0\u9ad8\u6548\u5730\u8fdb\u884c\u6570\u636e\u6e05\u6d17\u548c\u5904\u7406\uff0c\u4e3a\u540e\u7eed\u7684\u6570\u636e\u5206\u6790\u548c\u5efa\u6a21\u6253\u4e0b\u575a\u5b9e\u7684\u57fa\u7840\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff0c\u795d\u4f60\u5728\u6570\u636e\u5206\u6790\u7684\u9053\u8def\u4e0a\u53d6\u5f97\u66f4\u5927\u7684\u8fdb\u6b65\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Pandas\u5220\u9664DataFrame\u4e2d\u7684\u591a\u5217\uff1f<\/strong><br \/>\u5728Pandas\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a\u8981\u5220\u9664\u7684\u5217\u540d\u5217\u8868\u6765\u4e00\u6b21\u6027\u5220\u9664\u591a\u4e2a\u5217\u3002\u4f7f\u7528<code>drop()<\/code>\u65b9\u6cd5\u65f6\uff0c\u5c06<code>axis<\/code>\u53c2\u6570\u8bbe\u7f6e\u4e3a1\uff0c\u5e76\u4f20\u5165\u4e00\u4e2a\u5305\u542b\u5217\u540d\u7684\u5217\u8868\u3002\u4f8b\u5982\uff0c<code>df.drop([&#39;column1&#39;, &#39;column2&#39;], axis=1, inplace=True)<\/code>\u5c06\u540c\u65f6\u5220\u9664&quot;column1&quot;\u548c&quot;column2&quot;\u3002<\/p>\n<p><strong>\u5728\u5220\u9664\u5217\u540e\uff0c\u5982\u4f55\u786e\u8ba4DataFrame\u7684\u53d8\u5316\uff1f<\/strong><br \/>\u5220\u9664\u5217\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>df.info()<\/code>\u6216<code>df.head()<\/code>\u65b9\u6cd5\u6765\u67e5\u770bDataFrame\u7684\u7ed3\u6784\u548c\u524d\u51e0\u884c\u6570\u636e\u3002\u8fd9\u4e24\u79cd\u65b9\u6cd5\u80fd\u591f\u5e2e\u52a9\u7528\u6237\u786e\u8ba4\u6240\u9700\u7684\u5217\u5df2\u7ecf\u6210\u529f\u5220\u9664\uff0c\u5e76\u67e5\u770b\u5269\u4f59\u6570\u636e\u7684\u72b6\u6001\u3002<\/p>\n<p><strong>\u5982\u679c\u6211\u9519\u8bef\u5730\u5220\u9664\u4e86\u4e00\u5217\uff0c\u5982\u4f55\u6062\u590d\u5b83\uff1f<\/strong><br \/>\u5982\u679c\u5728\u5220\u9664\u5217\u65f6\u4f7f\u7528\u4e86<code>inplace=True<\/code>\uff0c\u8be5\u5217\u5c06\u65e0\u6cd5\u76f4\u63a5\u6062\u590d\u3002\u4e3a\u4e86\u9632\u6b62\u6570\u636e\u4e22\u5931\uff0c\u5efa\u8bae\u5728\u5220\u9664\u4e4b\u524d\u5907\u4efdDataFrame\uff0c\u4f8b\u5982\u901a\u8fc7<code>df_backup = df.copy()<\/code>\u3002\u5982\u679c\u6ca1\u6709\u5907\u4efd\uff0c\u53ef\u4ee5\u8003\u8651\u91cd\u65b0\u8bfb\u53d6\u539f\u59cb\u6570\u636e\u6e90\uff0c\u6216\u8005\u5982\u679c\u6709\u64cd\u4f5c\u65e5\u5fd7\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u8fd8\u539f\u5230\u4e4b\u524d\u7684\u72b6\u6001\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u7684Pandas\u5e93\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528drop\u65b9\u6cd5\u5220\u9664\u67d0\u5217\u3001\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5217\u540d\u7684\u65b9\u5f0f\u4f7f\u7528del\u5173\u952e\u5b57\u6765\u5220\u9664\u3002\u4e0b [&hellip;]","protected":false},"author":3,"featured_media":1072071,"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\/1072060"}],"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=1072060"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1072060\/revisions"}],"predecessor-version":[{"id":1072073,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1072060\/revisions\/1072073"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1072071"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1072060"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1072060"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1072060"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}