{"id":204797,"date":"2025-05-29T15:29:51","date_gmt":"2025-05-29T07:29:51","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204797\/"},"modified":"2025-05-29T15:29:51","modified_gmt":"2025-05-29T07:29:51","slug":"pandas-pop-%e6%96%b9%e6%b3%95-python%e6%95%b0%e6%8d%ae%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204797\/","title":{"rendered":"Pandas Pop() \u65b9\u6cd5 | Python\u6570\u636e\u5206\u6790"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Pandas Pop() \u65b9\u6cd5 | Python\u6570\u636e\u5206\u6790<\/h1>\n<p><span style=\"font-size: 15px\">\u6709\u5fd7\u8005\uff0c\u4e8b\u7adf\u6210\uff01\u5982\u679c\u4f60\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\uff0c\u90a3\u4e48\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aPandas Pop() \u65b9\u6cd5 | Python\u6570\u636e\u5206\u6790\u300b<\/span>\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff01\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241116\/17317494226738662ec224a.png\" class=\"aligncenter\"><\/p>\n<p>\u5728\u672c\u5b9e\u9a8c\u4e2d\uff0c\u6211\u4eec\u5c06\u63a2\u7d22 python pandas \u5e93\u4e2d\u7684 pop() \u65b9\u6cd5\u3002 pop() \u65b9\u6cd5\u7528\u4e8e\u5220\u9664\u6216\u5220\u9664 dataframe \u4e2d\u7684\u6307\u5b9a\u9879\u76ee\u5e76\u8fd4\u56de\u8be5\u9879\u76ee\u3002\u5982\u679c\u672a\u627e\u5230\u6307\u5b9a\u7684\u9879\u76ee\uff0c\u8be5\u65b9\u6cd5\u4f1a\u5f15\u53d1 keyerror\u3002<\/p>\n<p>\u865a\u62df\u673a\u542f\u52a8\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u5de6\u4e0a\u89d2\u5207\u6362\u5230<strong>notebook<\/strong>\u9009\u9879\u5361\uff0c\u8bbf\u95eejupyter notebook\u8fdb\u884c\u7ec3\u4e60\u3002<\/p>\n<p>\u6709\u65f6\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u7b49\u5f85\u51e0\u79d2\u949f jupyter notebook \u624d\u80fd\u5b8c\u6210\u52a0\u8f7d\u3002\u7531\u4e8e jupyter notebook \u7684\u9650\u5236\uff0c\u64cd\u4f5c\u9a8c\u8bc1\u65e0\u6cd5\u81ea\u52a8\u5316\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5728\u5b66\u4e60\u8fc7\u7a0b\u4e2d\u9047\u5230\u95ee\u9898\uff0c\u8bf7\u968f\u65f6\u8be2\u95eelabby\u3002\u4f1a\u540e\u53cd\u9988\uff0c\u6211\u4eec\u4f1a\u53ca\u65f6\u4e3a\u60a8\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5bfc\u5165 pandas \u5e93\u624d\u80fd\u4f7f\u7528 pop() \u65b9\u6cd5\u3002<\/p>\n<pre>import pandas as pd\n<\/pre>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 dataframe() \u6784\u9020\u51fd\u6570\u521b\u5efa\u4e00\u4e2a dataframe \u5bf9\u8c61\u3002\u6211\u4eec\u5c06\u4f20\u9012\u4e00\u4e2a\u5305\u542b\u5217\u6807\u7b7e\u53ca\u5176\u76f8\u5e94\u503c\u7684\u5b57\u5178\u3002<\/p>\n<pre>df = pd.dataframe({'name': ['pooja', 'sindu', 'renuka'], 'age': [18, 25, 20], 'height': [145, 155, 165], 'weight': [45, 55, 65]})\n<\/pre>\n<p>\u73b0\u5728\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 pop() \u65b9\u6cd5\u4ece dataframe \u4e2d\u5220\u9664\u6307\u5b9a\u7684\u9879\u76ee\u3002\u8be5\u65b9\u6cd5\u4ee5\u8981\u5f39\u51fa\u7684\u5217\u7684\u6807\u7b7e\u4f5c\u4e3a\u53c2\u6570\u3002<\/p>\n<pre>df.pop('age')\n<\/pre>\n<p>\u6700\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u6253\u5370\u4fee\u6539\u540e\u7684dataframe\u6765\u67e5\u770b\u53d8\u5316\u3002<\/p>\n<pre>print(df)\n<\/pre>\n<p>\u8fd9\u662f\u5b8c\u6574\u7684\u4ee3\u7801\uff1a<\/p>\n<pre>import pandas as pd\n\ndf = pd.DataFrame({'Name': ['Pooja', 'Sindu', 'Renuka'], 'Age': [18, 25, 20], 'Height': [145, 155, 165], 'Weight': [45, 55, 65]})\n\ndf.pop('Age')\n\nprint(df)\n<\/pre>\n<p>\u5728\u672c\u5b9e\u9a8c\u4e2d\uff0c\u6211\u4eec\u5b66\u4e60\u4e86\u5982\u4f55\u4f7f\u7528 python pandas \u5e93\u4e2d\u7684 pop() \u65b9\u6cd5\u6765\u5220\u200b\u200b\u9664\u6216\u5220\u9664 dataframe \u4e2d\u7684\u6307\u5b9a\u9879\u76ee\u3002\u6211\u4eec\u8fd8\u5b66\u4e60\u4e86\u5982\u679c\u5728 dataframe \u4e2d\u627e\u4e0d\u5230\u6307\u5b9a\u7684\u9879\u76ee\uff0c\u5982\u4f55\u5904\u7406 keyerror\u3002 pop() \u65b9\u6cd5\u662f\u5728 python \u4e2d\u64cd\u4f5c\u548c\u4fee\u6539 dataframe \u7684\u6709\u7528\u5de5\u5177\u3002<\/p>\n<hr>\n<blockquote>\n<p>? \u7acb\u5373\u7ec3\u4e60\uff1apandas dataframe pop \u65b9\u6cd5<\/p>\n<\/blockquote>\n<hr>\n<ul>\n<li>? \u5b66\u4e60\u6700\u65b0\u7684python\u6280\u80fd\u6811 <\/li>\n<li>? \u9605\u8bfb\u66f4\u591a python \u6559\u7a0b <\/li>\n<li>? \u52a0\u5165\u6211\u4eec\u7684 discord \u6216\u53d1\u63a8\u6587@wearelabex <\/li>\n<\/ul>\n<p>\u672c\u7bc7\u5173\u4e8e\u300aPandas Pop() \u65b9\u6cd5 | Python\u6570\u636e\u5206\u6790\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7\uff01<\/p>\n<p>      \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1adev.to \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb\u5220\u9664<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pandas Pop() \u65b9\u6cd5 &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-204797","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=204797"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204797\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}