{"id":187001,"date":"2020-10-25T08:03:39","date_gmt":"2020-10-25T00:03:39","guid":{"rendered":"http:\/\/4563.org\/?p=187001"},"modified":"2020-10-25T08:03:39","modified_gmt":"2020-10-25T00:03:39","slug":"%e6%9c%89%e4%bb%80%e4%b9%88%e5%a5%bd%e5%8a%9e%e6%b3%95%ef%bc%8c%e8%ae%a9-pandas-%e7%9a%84%e5%88%97%e4%bd%8d%e7%bd%ae%e4%ba%92%e6%8d%a2%e5%91%a2%ef%bc%8c%e6%af%94%e5%a6%82%e8%af%b4%ef%bc%8c%e7%ac%ac-3","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=187001","title":{"rendered":"\u6709\u4ec0\u4e48\u597d\u529e\u6cd5\uff0c\u8ba9 pandas \u7684\u5217\u4f4d\u7f6e\u4e92\u6362\u5462\uff0c\u6bd4\u5982\u8bf4\uff0c\u7b2c 3 \u5217\u6362\u5230\u7b2c\u4e00\u5217\u53bb"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6709\u4ec0\u4e48\u597d\u529e\u6cd5\uff0c\u8ba9 pandas \u7684\u5217\u4f4d\u7f6e\u4e92\u6362\u5462\uff0c\u6bd4\u5982\u8bf4\uff0c\u7b2c 3 \u5217\u6362\u5230\u7b2c\u4e00\u5217\u53bb               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : galileo1214 <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u6211\u767e\u5ea6\u641c\u4e86\u4e0b\uff0c\u6ca1\u5565\u597d\u529e\u6cd5\u554a      <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4041737\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zyuu2 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u81ea\u5df1\u6307\u5b9a\u5217\u7684\u987a\u5e8f<br \/>&#8220;`<br \/>import pandas as pd<br \/>df = pd.DataFrame({&#8216;a&#8217;: [1,2], &#8216;b&#8217;: [3,4], &#8216;c&#8217;: [5,6]})<br \/>df<br \/>Out[4]: <br \/> a b c<br \/>0 1 3 5<br \/>1 2 4 6<br \/>df = df[[&#8216;b&#8217;, &#8216;c&#8217;, &#8216;a&#8217;]]<br \/>df<br \/>Out[6]: <br \/> b c a<br \/>0 3 5 1<br \/>1 4 6 2<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4041738\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tikazyq <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u4e2a\u5e94\u8be5\u662f\u57fa\u7840\u64cd\u4f5c\u4e86\uff0c\u7b80\u5355\u6765\u8bf4\uff0c\u5c31\u662f\u628a columns \u4e2d\u7684\u5143\u7d20\u8c03\u6362\u4e00\u4e0b\uff0c\u7136\u540e\u9009\u62e9\u5c31\u53ef\u4ee5\u4e86\u3002\u611f\u89c9\u5bf9 pandas \u8fd8\u662f\u4e0d\u719f\u6089\u54e6\uff0c\u8981\u591a\u8bfb\u4e00\u4e0b\u6587\u6863\uff0c\u4e0a\u9762\u975e\u5e38\u8be6\u7ec6                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4041739\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : galileo1214 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zyuu2 #1 \u8fd9\u4e2a\u5217\u5c11\u8fd8\u597d\u70b9\uff0c\u5217\u591a\u5c31\u4e0d\u597d\u64cd\u4f5c<br \/>\u76ee\u524d\u662f\u5b58\u4e00\u4e2a\uff0cdrop \u4e0b\uff0cinsert \u4e0b\uff0c\u5c31\u95ee\u95ee\u770b\u6709\u4ec0\u4e48\u81ea\u5e26\u51fd\u6570\u4e48                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4041740\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : shikimoon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             df.reindex(columns=[&#8216;c&#8217;, &#8216;b&#8217;, &#8216;a&#8217;)                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4041741\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Battle <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u662f\u8981\u8ddf sql \u4e00\u6837\u7684\u64cd\u4f5c\u8fdb\u884c\u6362\u5217\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4041742\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : bugcoder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5047\u8bbe\u5f88\u591a\u5217\uff0c\u60f3\u628a\u2018mean\u2019 \u5217\u6362\u5230\u524d\u9762<\/p>\n<p>&#8220;&#8220;python<br \/>df = df[ [&#8216;mean&#8217;] + [ col for col in df.columns if col != &#8216;mean&#8217; ] ]<br \/>&#8220;&#8220;<\/p>\n<p>https:\/\/stackoverflow.com\/questions\/13148429\/how-to-change-the-order-of-dataframe-columns                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4041743\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : galileo1214 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @bugcoder #6 \u8fd9\u4e2a\u8fd8\u884c\uff0c\u591a\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4041744\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Kobayashi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u77e9\u9635\u8bba\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u4ec0\u4e48\u597d\u529e\u6cd5\uff0c\u8ba9 pandas \u7684&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/187001"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=187001"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/187001\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=187001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=187001"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=187001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}