{"id":50715,"date":"2024-12-03T13:56:36","date_gmt":"2024-12-03T05:56:36","guid":{"rendered":"https:\/\/fwq.ai\/blog\/50715\/"},"modified":"2024-12-03T13:56:36","modified_gmt":"2024-12-03T05:56:36","slug":"numpy-%e4%b8%ad%e7%9a%84-unique-%e5%87%bd%e6%95%b0%e4%b8%ba%e4%bb%80%e4%b9%88%e8%87%aa%e5%8a%a8%e6%8e%92%e5%ba%8f%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/50715\/","title":{"rendered":"NumPy \u4e2d\u7684 unique \u51fd\u6570\u4e3a\u4ec0\u4e48\u81ea\u52a8\u6392\u5e8f\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>NumPy \u4e2d\u7684 unique \u51fd\u6570\u4e3a\u4ec0\u4e48\u81ea\u52a8\u6392\u5e8f\uff1f<\/h1>\n<p>\u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u662f\u7ed3\u5408\u6211\u4e4b\u524d\u9762\u8bd5\u7684\u5404\u79cd\u7ecf\u5386\u548c\u5b9e\u6218\u5f00\u53d1\u4e2d\u9047\u5230\u7684\u95ee\u9898\u89e3\u51b3\u7ecf\u9a8c\u6574\u7406\u7684\uff0c\u5e0c\u671b\u8fd9\u7bc7\u300aNumPy \u4e2d\u7684 unique \u51fd\u6570\u4e3a\u4ec0\u4e48\u81ea\u52a8\u6392\u5e8f\uff1f\u300b\u5bf9\u4f60\u6709\u5f88\u5927\u5e2e\u52a9\uff01\u6b22\u8fce\u6536\u85cf\uff0c\u5206\u4eab\u7ed9\u66f4\u591a\u7684\u9700\u8981\u7684\u670b\u53cb\u5b66\u4e60~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241126\/17325958196745506b6d491.jpg\" class=\"aligncenter\" title=\"NumPy \u4e2d\u7684 unique \u51fd\u6570\u4e3a\u4ec0\u4e48\u81ea\u52a8\u6392\u5e8f\uff1f\u63d2\u56fe\" alt=\"NumPy \u4e2d\u7684 unique \u51fd\u6570\u4e3a\u4ec0\u4e48\u81ea\u52a8\u6392\u5e8f\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>NumPy \u4e2d\u7684 unique \u51fd\u6570\u81ea\u52a8\u6392\u5e8f\u7684\u539f\u56e0<\/strong><\/p>\n<p>NumPy \u4e2d\u7684 unique \u51fd\u6570\u7528\u4e8e\u67e5\u627e\u6570\u7ec4\u4e2d\u7684\u552f\u4e00\u503c\u5e76\u8fd4\u56de\u4e00\u4e2a\u65b0\u6570\u7ec4\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e2a\u51fd\u6570\u4f1a\u81ea\u52a8\u5bf9\u8fd4\u56de\u7684\u552f\u4e00\u503c\u8fdb\u884c\u6392\u5e8f\u3002<\/p>\n<p><strong>\u4e3a\u4ec0\u4e48\u4f1a\u81ea\u52a8\u6392\u5e8f\uff1f<\/strong><\/p>\n<p>unique \u51fd\u6570\u81ea\u52a8\u6392\u5e8f\u7684\u539f\u56e0\u662f\u56e0\u4e3a\u5b83\u4f7f\u7528\u4e86 NumPy \u5e93\u4e2d\u7684\u6392\u5e8f\u7b97\u6cd5\u6765\u67e5\u627e\u552f\u4e00\u503c\u3002\u8fd9\u4e9b\u7b97\u6cd5\u7684\u76ee\u7684\u662f\u751f\u6210\u4e00\u4e2a\u6709\u5e8f\u7684\u552f\u4e00\u503c\u5217\u8868\u3002<\/p>\n<p><strong>dtype \u5bf9\u6392\u5e8f\u7684\u5f71\u54cd<\/strong><\/p>\n<p>\u5f53\u6570\u7ec4\u5305\u542b\u975e\u6570\u5b57\u5143\u7d20\uff08\u5982\u5b57\u7b26\u4e32\uff09\u65f6\uff0cdtype \u53c2\u6570\u53ef\u4ee5\u6307\u5b9a\u5143\u7d20\u7684\u7c7b\u578b\u3002\u4f8b\u5982\uff0c\u5728\u4e0a\u4f8b\u4e2d\u4f7f\u7528 dtype='&lt;U6&#8242; \u8868\u793a\u6570\u7ec4\u5305\u542b\u957f\u4e3a 6 \u4e2a\u5b57\u7b26\u7684\u5b57\u7b26\u4e32\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cunique \u51fd\u6570\u4ecd\u4f1a\u81ea\u52a8\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u6392\u5e8f\u3002<\/p>\n<p><strong>\u66f4\u6539\u6392\u5e8f\u884c\u4e3a<\/strong><\/p>\n<p>\u5982\u679c\u4e0d\u60f3\u5bf9\u8fd4\u56de\u7684\u552f\u4e00\u503c\u8fdb\u884c\u6392\u5e8f\uff0c\u53ef\u4ee5\u4f7f\u7528 return_index=True \u53c2\u6570\u3002\u8fd9\u5c06\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u552f\u4e00\u503c\u4ee5\u53ca\u5b83\u4eec\u5728\u539f\u59cb\u6570\u7ec4\u4e2d\u7684\u4f4d\u7f6e\u7684\u5143\u7ec4\u3002<\/p>\n<p>\u4eca\u5929\u5173\u4e8e\u300aNumPy \u4e2d\u7684 unique \u51fd\u6570\u4e3a\u4ec0\u4e48\u81ea\u52a8\u6392\u5e8f\uff1f\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NumPy \u4e2d\u7684 unique \u51fd\u6570\u4e3a\u4ec0\u4e48\u81ea\u52a8\u6392\u5e8f\uff1f \u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u662f\u7ed3\u5408\u6211\u4e4b\u524d\u9762\u8bd5\u7684\u5404\u79cd\u7ecf\u5386\u548c\u5b9e\u6218\u5f00\u53d1\u4e2d\u9047\u5230\u7684\u95ee\u9898\u89e3\u51b3\u7ecf\u9a8c\u6574\u7406\u7684\uff0c\u5e0c\u671b\u8fd9\u7bc7\u300aNumPy \u4e2d\u7684 unique \u51fd\u6570\u4e3a\u4ec0\u4e48\u81ea\u52a8\u6392\u5e8f\uff1f\u300b\u5bf9\u4f60\u6709\u5f88\u5927\u5e2e\u52a9\uff01\u6b22\u8fce\u6536\u85cf\uff0c\u5206\u4eab\u7ed9\u66f4\u591a\u7684\u9700\u8981\u7684\u670b\u53cb\u5b66\u4e60~ NumPy \u4e2d\u7684 unique \u51fd\u6570\u81ea\u52a8\u6392\u5e8f\u7684\u539f\u56e0 NumPy \u4e2d\u7684 unique \u51fd\u6570\u7528\u4e8e\u67e5\u627e\u6570\u7ec4\u4e2d\u7684\u552f\u4e00\u503c\u5e76\u8fd4\u56de\u4e00\u4e2a\u65b0\u6570\u7ec4\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e2a\u51fd\u6570\u4f1a\u81ea\u52a8\u5bf9\u8fd4\u56de\u7684\u552f\u4e00\u503c\u8fdb\u884c\u6392\u5e8f\u3002 \u4e3a\u4ec0\u4e48\u4f1a\u81ea\u52a8\u6392\u5e8f\uff1f unique \u51fd\u6570\u81ea\u52a8\u6392\u5e8f\u7684\u539f\u56e0\u662f\u56e0\u4e3a\u5b83\u4f7f\u7528\u4e86 NumPy \u5e93\u4e2d\u7684\u6392\u5e8f\u7b97\u6cd5\u6765\u67e5\u627e\u552f\u4e00\u503c\u3002\u8fd9\u4e9b\u7b97\u6cd5\u7684\u76ee\u7684\u662f\u751f\u6210\u4e00\u4e2a\u6709\u5e8f\u7684\u552f\u4e00\u503c\u5217\u8868\u3002 dtype \u5bf9\u6392\u5e8f\u7684\u5f71\u54cd \u5f53\u6570\u7ec4\u5305\u542b\u975e\u6570\u5b57\u5143\u7d20\uff08\u5982\u5b57\u7b26\u4e32\uff09\u65f6\uff0cdtype \u53c2\u6570\u53ef\u4ee5\u6307\u5b9a\u5143\u7d20\u7684\u7c7b\u578b\u3002\u4f8b\u5982\uff0c\u5728\u4e0a\u4f8b\u4e2d\u4f7f\u7528 dtype='&lt;U6&#8242; \u8868\u793a\u6570\u7ec4\u5305\u542b\u957f\u4e3a 6 \u4e2a\u5b57\u7b26\u7684\u5b57\u7b26\u4e32\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cunique \u51fd\u6570\u4ecd\u4f1a\u81ea\u52a8\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u6392\u5e8f\u3002 \u66f4\u6539\u6392\u5e8f\u884c\u4e3a \u5982\u679c\u4e0d\u60f3\u5bf9\u8fd4\u56de\u7684\u552f\u4e00\u503c\u8fdb\u884c\u6392\u5e8f\uff0c\u53ef\u4ee5\u4f7f\u7528 return_index=True \u53c2\u6570\u3002\u8fd9\u5c06\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u552f\u4e00\u503c\u4ee5\u53ca\u5b83\u4eec\u5728\u539f\u59cb\u6570\u7ec4\u4e2d\u7684\u4f4d\u7f6e\u7684\u5143\u7ec4\u3002 \u4eca\u5929\u5173\u4e8e\u300aNumPy \u4e2d\u7684 unique \u51fd\u6570\u4e3a\u4ec0\u4e48\u81ea\u52a8\u6392\u5e8f\uff1f\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/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-50715","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/50715","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=50715"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/50715\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=50715"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=50715"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=50715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}