{"id":829,"date":"2024-11-07T09:04:04","date_gmt":"2024-11-07T01:04:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/829\/"},"modified":"2024-11-07T09:04:04","modified_gmt":"2024-11-07T01:04:04","slug":"%e5%a6%82%e4%bd%95%e4%b8%ba%e4%b8%80%e5%88%97%e6%95%b0%e6%8d%ae%e4%b8%ad%e7%9a%84%e7%9b%b8%e5%90%8c%e5%80%bc%e6%89%93%e4%b8%8a%e7%9b%b8%e5%90%8c%e5%ba%8f%e5%8f%b7%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/829\/","title":{"rendered":"\u5982\u4f55\u4e3a\u4e00\u5217\u6570\u636e\u4e2d\u7684\u76f8\u540c\u503c\u6253\u4e0a\u76f8\u540c\u5e8f\u53f7\uff1f"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1076\" src=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172993684041176.jpg\" width=\"800\" height=\"320\" srcset=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172993684041176.jpg 800w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172993684041176-300x120.jpg 300w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172993684041176-768x307.jpg 768w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172993684041176-670x268.jpg 670w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" title=\"\u5982\u4f55\u4e3a\u4e00\u5217\u6570\u636e\u4e2d\u7684\u76f8\u540c\u503c\u6253\u4e0a\u76f8\u540c\u5e8f\u53f7\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4e3a\u4e00\u5217\u6570\u636e\u4e2d\u7684\u76f8\u540c\u503c\u6253\u4e0a\u76f8\u540c\u5e8f\u53f7\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u89e3\u51b3\u6839\u636e\u4e00\u5217\u6570\u636e\u4e3a\u76f8\u540c\u503c\u6253\u4e0a\u76f8\u540c\u5e8f\u53f7<\/strong><\/p>\n<p>\u4f60\u60f3\u4e3a\u4e00\u5217\u6570\u636e\u6253\u4e0a\u5e8f\u53f7\uff0c\u4e0a\u4e0b\u76f8\u540c\u6570\u636e\u6253\u76f8\u540c\u5e8f\u53f7\uff0c\u4e0d\u540c\u6570\u636e\u5e8f\u53f7+1\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u6b64\u529f\u80fd\u7684 python \u4ee3\u7801\uff1a<\/p>\n<pre>import numpy as np\nimport pandas as pd\n\ndf = pd.dataframe({\n    'data': [11, 21, 24, 24, 24, 24, 25, 25, 26, 26, 26, 26, 23, 26, 26, 26, 26, 20, 26, 26, 26, 26],\n    'nums': 0,\n})\n\ndf['nums'] = np.cumsum(df['data'].diff() != 0)\n\nprint(df)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u4ee3\u7801\u5c06\u4ea7\u751f\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<pre>    data  nums\n0     11     1\n1     21     2\n2     24     3\n3     24     3\n4     24     3\n5     24     3\n6     25     4\n7     25     4\n8     26     5\n9     26     5\n10    26     5\n11    26     5\n12    23     6\n13    26     7\n14    26     7\n15    26     7\n16    26     7\n17    20     8\n18    26     9\n19    26     9\n20    26     9\n21    26     9<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b63\u5982\u4f60\u6240\u89c1\uff0c\u76f8\u540c\u6570\u636e\u5df2\u88ab\u5206\u914d\u76f8\u540c\u7684\u5e8f\u53f7\uff0c\u800c\u4e0d\u540c\u6570\u636e\u5219\u83b7\u5f97\u4e86\u4e0d\u540c\u7684\u5e8f\u53f7\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4e3a\u4e00\u5217\u6570\u636e\u4e2d\u7684\u76f8\u540c\u503c\u6253\u4e0a\u76f8\u540c\u5e8f\u53f7\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u51b3\u6839\u636e\u4e00\u5217\u6570\u636e\u4e3a\u76f8\u540c\u503c\u6253\u4e0a\u76f8\u540c\u5e8f\u53f7 \u4f60\u60f3\u4e3a\u4e00\u5217\u6570\u636e\u6253\u4e0a\u5e8f\u53f7\uff0c\u4e0a\u4e0b\u76f8\u540c\u6570\u636e\u6253\u76f8\u540c\u5e8f\u53f7\uff0c\u4e0d\u540c\u6570\u636e\u5e8f\u53f7+1\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u6b64\u529f\u80fd\u7684 python \u4ee3\u7801\uff1a import numpy as np import pandas as pd df = pd.dataframe({ &#8216;data&#8217;: [11, 21, 24, 24, 24, 24, 25, 25, 26, 26, 26, 26, 23, 26, 26, 26, 26, 20, 26, 26, 26, 26], &#8216;nums&#8217;: 0, }) df[&#8216;nums&#8217;] = np.cumsum(df[&#8216;data&#8217;].diff() != 0) print(df) \u767b\u5f55\u540e\u590d\u5236 \u6b64\u4ee3\u7801\u5c06\u4ea7\u751f\u4ee5\u4e0b\u8f93\u51fa\uff1a data nums 0 11 1 1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-829","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/829","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=829"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/829\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}