{"id":1156308,"date":"2025-01-13T18:14:19","date_gmt":"2025-01-13T10:14:19","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1156308.html"},"modified":"2025-01-13T18:14:22","modified_gmt":"2025-01-13T10:14:22","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8python%e5%90%88%e5%b9%b6%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1156308.html","title":{"rendered":"\u5982\u4f55\u5728python\u5408\u5e76\u6570\u636e"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25194754\/8f24e738-d97b-489b-8b9f-154b4ea740fc.webp\" alt=\"\u5982\u4f55\u5728python\u5408\u5e76\u6570\u636e\" \/><\/p>\n<p><p> \u5728Python\u4e2d\u5408\u5e76\u6570\u636e\u7684\u5e38\u7528\u65b9\u6cd5\u6709<strong>\u4f7f\u7528pandas\u5e93\u3001\u4f7f\u7528numpy\u5e93\u3001\u4f7f\u7528\u5185\u7f6e\u7684zip\u51fd\u6570\u3001\u4f7f\u7528\u94fe\u8868\u548c\u5b57\u5178<\/strong>\u3002\u5176\u4e2d\uff0c\u6700\u5e38\u7528\u548c\u529f\u80fd\u6700\u5f3a\u5927\u7684\u65b9\u6cd5\u662f\u4f7f\u7528pandas\u5e93\u3002pandas\u63d0\u4f9b\u4e86\u591a\u79cd\u6570\u636e\u5408\u5e76\u65b9\u6cd5\uff0c\u5982merge\u3001concat\u548cjoin\u7b49\uff0c\u5176\u4e2dmerge\u65b9\u6cd5\u6700\u4e3a\u5e38\u89c1\uff0c\u9002\u7528\u4e8e\u5927\u591a\u6570\u60c5\u51b5\u3002<strong>pandas\u5e93\u7684merge\u65b9\u6cd5\u53ef\u4ee5\u6839\u636e\u67d0\u4e2a\u6216\u67d0\u4e9b\u5171\u540c\u7684\u5217\uff0c\u5c06\u4e24\u4e2a\u6216\u591a\u4e2aDataFrame\u5408\u5e76\u6210\u4e00\u4e2aDataFrame<\/strong>\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528pandas\u5e93\u5408\u5e76\u6570\u636e<\/h3>\n<\/p>\n<p><p>pandas\u5e93\u662fPython\u4e2d\u5904\u7406\u6570\u636e\u7684\u5f3a\u5927\u5de5\u5177\uff0c\u7279\u522b\u9002\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u6570\u636e\u79d1\u5b66\u4efb\u52a1\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u5408\u5e76\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001merge\u65b9\u6cd5<\/h4>\n<\/p>\n<p><p>merge\u65b9\u6cd5\u662fpandas\u4e2d\u6700\u5e38\u7528\u7684\u5408\u5e76\u65b9\u6cd5\u3002\u5b83\u53ef\u4ee5\u6839\u636e\u4e00\u4e2a\u6216\u591a\u4e2a\u952e\u5c06\u4e24\u4e2aDataFrame\u5408\u5e76\u3002merge\u65b9\u6cd5\u7684\u53c2\u6570\u5305\u62ecleft\u3001right\u3001how\u3001on\u7b49\uff0c\u5206\u522b\u4ee3\u8868\u5de6\u8868\u3001\u53f3\u8868\u3001\u5408\u5e76\u65b9\u5f0f\u548c\u5408\u5e76\u952e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e24\u4e2aDataFrame<\/strong><\/h2>\n<p>df1 = pd.DataFrame({<\/p>\n<p>    &#39;key&#39;: [&#39;A&#39;, &#39;B&#39;, &#39;C&#39;, &#39;D&#39;],<\/p>\n<p>    &#39;value1&#39;: [1, 2, 3, 4]<\/p>\n<p>})<\/p>\n<p>df2 = pd.DataFrame({<\/p>\n<p>    &#39;key&#39;: [&#39;B&#39;, &#39;C&#39;, &#39;D&#39;, &#39;E&#39;],<\/p>\n<p>    &#39;value2&#39;: [5, 6, 7, 8]<\/p>\n<p>})<\/p>\n<h2><strong>\u4f7f\u7528merge\u65b9\u6cd5\u5408\u5e76<\/strong><\/h2>\n<p>result = pd.merge(df1, df2, on=&#39;key&#39;, how=&#39;inner&#39;)<\/p>\n<p>print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2aDataFrame\uff0c\u5e76\u6839\u636e\u5171\u540c\u7684\u5217\u201ckey\u201d\u4f7f\u7528inner join\u8fdb\u884c\u5408\u5e76\u3002\u7ed3\u679c\u662f\u4e00\u4e2a\u65b0\u7684DataFrame\uff0c\u53ea\u5305\u542b\u5728\u4e24\u4e2a\u539f\u59cbDataFrame\u4e2d\u90fd\u51fa\u73b0\u7684\u952e\u3002<\/p>\n<\/p>\n<p><h4>2\u3001concat\u65b9\u6cd5<\/h4>\n<\/p>\n<p><p>concat\u65b9\u6cd5\u7528\u4e8e\u6cbf\u4e00\u4e2a\u8f74\u5c06\u591a\u4e2aDataFrame\u6216Series\u5bf9\u8c61\u5408\u5e76\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e\u5782\u76f4\u6216\u6c34\u5e73\u5408\u5e76\uff0c\u5e76\u4e14\u652f\u6301\u6dfb\u52a0\u5c42\u6b21\u5316\u7d22\u5f15\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e24\u4e2aDataFrame<\/p>\n<p>df3 = pd.DataFrame({<\/p>\n<p>    &#39;A&#39;: [&#39;A0&#39;, &#39;A1&#39;, &#39;A2&#39;, &#39;A3&#39;],<\/p>\n<p>    &#39;B&#39;: [&#39;B0&#39;, &#39;B1&#39;, &#39;B2&#39;, &#39;B3&#39;]<\/p>\n<p>})<\/p>\n<p>df4 = pd.DataFrame({<\/p>\n<p>    &#39;A&#39;: [&#39;A4&#39;, &#39;A5&#39;, &#39;A6&#39;, &#39;A7&#39;],<\/p>\n<p>    &#39;B&#39;: [&#39;B4&#39;, &#39;B5&#39;, &#39;B6&#39;, &#39;B7&#39;]<\/p>\n<p>})<\/p>\n<h2><strong>\u4f7f\u7528concat\u65b9\u6cd5\u5782\u76f4\u5408\u5e76<\/strong><\/h2>\n<p>result = pd.concat([df3, df4])<\/p>\n<p>print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2aDataFrame\uff0c\u5e76\u4f7f\u7528concat\u65b9\u6cd5\u5782\u76f4\u5408\u5e76\u5b83\u4eec\u3002\u7ed3\u679c\u662f\u4e00\u4e2a\u65b0\u7684DataFrame\uff0c\u5305\u542b\u4e86\u4e24\u4e2a\u539f\u59cbDataFrame\u7684\u6240\u6709\u884c\u3002<\/p>\n<\/p>\n<p><h4>3\u3001join\u65b9\u6cd5<\/h4>\n<\/p>\n<p><p>join\u65b9\u6cd5\u7528\u4e8e\u6839\u636e\u7d22\u5f15\u5c06\u4e24\u4e2aDataFrame\u5408\u5e76\u3002\u5b83\u7c7b\u4f3c\u4e8emerge\u65b9\u6cd5\uff0c\u4f46\u66f4\u9002\u7528\u4e8e\u57fa\u4e8e\u7d22\u5f15\u7684\u5408\u5e76\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e24\u4e2aDataFrame<\/p>\n<p>df5 = pd.DataFrame({<\/p>\n<p>    &#39;A&#39;: [&#39;A0&#39;, &#39;A1&#39;, &#39;A2&#39;],<\/p>\n<p>    &#39;B&#39;: [&#39;B0&#39;, &#39;B1&#39;, &#39;B2&#39;]<\/p>\n<p>}, index=[&#39;K0&#39;, &#39;K1&#39;, &#39;K2&#39;])<\/p>\n<p>df6 = pd.DataFrame({<\/p>\n<p>    &#39;C&#39;: [&#39;C0&#39;, &#39;C1&#39;, &#39;C2&#39;],<\/p>\n<p>    &#39;D&#39;: [&#39;D0&#39;, &#39;D1&#39;, &#39;D2&#39;]<\/p>\n<p>}, index=[&#39;K0&#39;, &#39;K2&#39;, &#39;K3&#39;])<\/p>\n<h2><strong>\u4f7f\u7528join\u65b9\u6cd5\u5408\u5e76<\/strong><\/h2>\n<p>result = df5.join(df6, how=&#39;inner&#39;)<\/p>\n<p>print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2aDataFrame\uff0c\u5e76\u4f7f\u7528join\u65b9\u6cd5\u6839\u636e\u7d22\u5f15\u8fdb\u884c\u5408\u5e76\u3002\u7ed3\u679c\u662f\u4e00\u4e2a\u65b0\u7684DataFrame\uff0c\u53ea\u5305\u542b\u5728\u4e24\u4e2a\u539f\u59cbDataFrame\u4e2d\u90fd\u51fa\u73b0\u7684\u7d22\u5f15\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528numpy\u5e93\u5408\u5e76\u6570\u636e<\/h3>\n<\/p>\n<p><p>numpy\u5e93\u662fPython\u4e2d\u5904\u7406\u6570\u7ec4\u548c\u77e9\u9635\u7684\u5f3a\u5927\u5de5\u5177\u3002\u867d\u7136\u5b83\u4e0d\u5982pandas\u5e93\u5728\u5904\u7406DataFrame\u65b9\u9762\u5f3a\u5927\uff0c\u4f46\u5728\u5904\u7406\u6570\u503c\u6570\u636e\u65f6\u975e\u5e38\u9ad8\u6548\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u5408\u5e76\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528numpy\u7684concatenate\u65b9\u6cd5<\/h4>\n<\/p>\n<p><p>concatenate\u65b9\u6cd5\u7528\u4e8e\u6cbf\u6307\u5b9a\u8f74\u5c06\u4e24\u4e2a\u6216\u591a\u4e2a\u6570\u7ec4\u5408\u5e76\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e\u5782\u76f4\u6216\u6c34\u5e73\u5408\u5e76\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e24\u4e2a\u6570\u7ec4<\/strong><\/h2>\n<p>arr1 = np.array([[1, 2], [3, 4]])<\/p>\n<p>arr2 = np.array([[5, 6], [7, 8]])<\/p>\n<h2><strong>\u4f7f\u7528concatenate\u65b9\u6cd5\u5782\u76f4\u5408\u5e76<\/strong><\/h2>\n<p>result = np.concatenate((arr1, arr2), axis=0)<\/p>\n<p>print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2a\u6570\u7ec4\uff0c\u5e76\u4f7f\u7528concatenate\u65b9\u6cd5\u5782\u76f4\u5408\u5e76\u5b83\u4eec\u3002\u7ed3\u679c\u662f\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\uff0c\u5305\u542b\u4e86\u4e24\u4e2a\u539f\u59cb\u6570\u7ec4\u7684\u6240\u6709\u884c\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528numpy\u7684hstack\u548cvstack\u65b9\u6cd5<\/h4>\n<\/p>\n<p><p>hstack\u548cvstack\u65b9\u6cd5\u5206\u522b\u7528\u4e8e\u6c34\u5e73\u548c\u5782\u76f4\u5408\u5e76\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528hstack\u65b9\u6cd5\u6c34\u5e73\u5408\u5e76<\/p>\n<p>result_h = np.hstack((arr1, arr2))<\/p>\n<p>print(result_h)<\/p>\n<h2><strong>\u4f7f\u7528vstack\u65b9\u6cd5\u5782\u76f4\u5408\u5e76<\/strong><\/h2>\n<p>result_v = np.vstack((arr1, arr2))<\/p>\n<p>print(result_v)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528hstack\u548cvstack\u65b9\u6cd5\u5206\u522b\u6c34\u5e73\u548c\u5782\u76f4\u5408\u5e76\u4e86\u4e24\u4e2a\u6570\u7ec4\u3002\u7ed3\u679c\u662f\u65b0\u7684\u6570\u7ec4\uff0c\u5305\u542b\u4e86\u4e24\u4e2a\u539f\u59cb\u6570\u7ec4\u7684\u6240\u6709\u5143\u7d20\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u5185\u7f6e\u7684zip\u51fd\u6570\u5408\u5e76\u6570\u636e<\/h3>\n<\/p>\n<p><p>zip\u51fd\u6570\u662fPython\u7684\u5185\u7f6e\u51fd\u6570\uff0c\u7528\u4e8e\u5c06\u591a\u4e2a\u53ef\u8fed\u4ee3\u5bf9\u8c61\u201c\u538b\u7f29\u201d\u6210\u4e00\u4e2a\u65b0\u7684\u53ef\u8fed\u4ee3\u5bf9\u8c61\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e\u5408\u5e76\u5217\u8868\u3001\u5143\u7ec4\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e24\u4e2a\u5217\u8868<\/p>\n<p>list1 = [1, 2, 3, 4]<\/p>\n<p>list2 = [&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;]<\/p>\n<h2><strong>\u4f7f\u7528zip\u51fd\u6570\u5408\u5e76<\/strong><\/h2>\n<p>result = list(zip(list1, list2))<\/p>\n<p>print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2a\u5217\u8868\uff0c\u5e76\u4f7f\u7528zip\u51fd\u6570\u5c06\u5b83\u4eec\u5408\u5e76\u6210\u4e00\u4e2a\u65b0\u7684\u5217\u8868\u3002\u7ed3\u679c\u662f\u4e00\u4e2a\u5305\u542b\u5143\u7ec4\u7684\u5217\u8868\uff0c\u6bcf\u4e2a\u5143\u7ec4\u5305\u542b\u539f\u59cb\u5217\u8868\u4e2d\u7684\u5bf9\u5e94\u5143\u7d20\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528\u94fe\u8868\u548c\u5b57\u5178\u5408\u5e76\u6570\u636e<\/h3>\n<\/p>\n<p><p>\u94fe\u8868\u548c\u5b57\u5178\u662fPython\u4e2d\u5e38\u7528\u7684\u6570\u636e\u7ed3\u6784\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5408\u5e76\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528\u94fe\u8868\u5408\u5e76<\/h4>\n<\/p>\n<p><p>\u94fe\u8868\u662f\u4e00\u79cd\u7ebf\u6027\u6570\u636e\u7ed3\u6784\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5143\u7d20\u90fd\u662f\u4e00\u4e2a\u8282\u70b9\uff0c\u5305\u542b\u6570\u636e\u548c\u6307\u5411\u4e0b\u4e00\u4e2a\u8282\u70b9\u7684\u6307\u9488\u3002\u53ef\u4ee5\u901a\u8fc7\u904d\u5386\u94fe\u8868\u5e76\u5c06\u8282\u70b9\u8fde\u63a5\u5728\u4e00\u8d77\u6765\u5408\u5e76\u4e24\u4e2a\u94fe\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u94fe\u8868\u8282\u70b9<\/p>\n<p>class Node:<\/p>\n<p>    def __init__(self, data):<\/p>\n<p>        self.data = data<\/p>\n<p>        self.next = None<\/p>\n<h2><strong>\u521b\u5efa\u4e24\u4e2a\u94fe\u8868<\/strong><\/h2>\n<p>head1 = Node(1)<\/p>\n<p>head1.next = Node(2)<\/p>\n<p>head1.next.next = Node(3)<\/p>\n<p>head2 = Node(4)<\/p>\n<p>head2.next = Node(5)<\/p>\n<p>head2.next.next = Node(6)<\/p>\n<h2><strong>\u5408\u5e76\u94fe\u8868<\/strong><\/h2>\n<p>def merge_linked_lists(head1, head2):<\/p>\n<p>    if not head1:<\/p>\n<p>        return head2<\/p>\n<p>    if not head2:<\/p>\n<p>        return head1<\/p>\n<p>    if head1.data &lt; head2.data:<\/p>\n<p>        head1.next = merge_linked_lists(head1.next, head2)<\/p>\n<p>        return head1<\/p>\n<p>    else:<\/p>\n<p>        head2.next = merge_linked_lists(head1, head2.next)<\/p>\n<p>        return head2<\/p>\n<p>result = merge_linked_lists(head1, head2)<\/p>\n<h2><strong>\u6253\u5370\u5408\u5e76\u540e\u7684\u94fe\u8868<\/strong><\/h2>\n<p>def print_linked_list(head):<\/p>\n<p>    current = head<\/p>\n<p>    while current:<\/p>\n<p>        print(current.data, end=&quot; -&gt; &quot;)<\/p>\n<p>        current = current.next<\/p>\n<p>    print(None)<\/p>\n<p>print_linked_list(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u94fe\u8868\u8282\u70b9\u7c7b\uff0c\u5e76\u521b\u5efa\u4e86\u4e24\u4e2a\u94fe\u8868\u3002\u7136\u540e\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9012\u5f52\u51fd\u6570\u6765\u5408\u5e76\u4e24\u4e2a\u94fe\u8868\uff0c\u5e76\u6253\u5370\u5408\u5e76\u540e\u7684\u94fe\u8868\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528\u5b57\u5178\u5408\u5e76<\/h4>\n<\/p>\n<p><p>\u5b57\u5178\u662f\u4e00\u79cd\u952e\u503c\u5bf9\u6570\u636e\u7ed3\u6784\uff0c\u53ef\u4ee5\u901a\u8fc7\u66f4\u65b0\u4e00\u4e2a\u5b57\u5178\u6765\u5408\u5e76\u4e24\u4e2a\u5b57\u5178\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e24\u4e2a\u5b57\u5178<\/p>\n<p>dict1 = {&#39;a&#39;: 1, &#39;b&#39;: 2}<\/p>\n<p>dict2 = {&#39;b&#39;: 3, &#39;c&#39;: 4}<\/p>\n<h2><strong>\u5408\u5e76\u5b57\u5178<\/strong><\/h2>\n<p>result = dict1.copy()<\/p>\n<p>result.update(dict2)<\/p>\n<p>print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2a\u5b57\u5178\uff0c\u5e76\u901a\u8fc7\u66f4\u65b0\u4e00\u4e2a\u5b57\u5178\u6765\u5408\u5e76\u5b83\u4eec\u3002\u7ed3\u679c\u662f\u4e00\u4e2a\u65b0\u7684\u5b57\u5178\uff0c\u5305\u542b\u4e86\u4e24\u4e2a\u539f\u59cb\u5b57\u5178\u7684\u6240\u6709\u952e\u503c\u5bf9\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u5176\u4ed6\u5408\u5e76\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u5408\u5e76\u6570\u636e\u7684\u65b9\u6cd5\uff0c\u5982\u4f7f\u7528itertools.ch<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n\u51fd\u6570\u5408\u5e76\u53ef\u8fed\u4ee3\u5bf9\u8c61\u3001\u4f7f\u7528collections\u6a21\u5757\u4e2d\u7684defaultdict\u5408\u5e76\u6570\u636e\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528itertools.chain\u51fd\u6570\u5408\u5e76\u53ef\u8fed\u4ee3\u5bf9\u8c61<\/h4>\n<\/p>\n<p><p>itertools.chain\u51fd\u6570\u53ef\u4ee5\u5c06\u591a\u4e2a\u53ef\u8fed\u4ee3\u5bf9\u8c61\u8fde\u63a5\u6210\u4e00\u4e2a\u65b0\u7684\u53ef\u8fed\u4ee3\u5bf9\u8c61\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import itertools<\/p>\n<h2><strong>\u521b\u5efa\u4e24\u4e2a\u5217\u8868<\/strong><\/h2>\n<p>list3 = [1, 2, 3]<\/p>\n<p>list4 = [4, 5, 6]<\/p>\n<h2><strong>\u4f7f\u7528itertools.chain\u51fd\u6570\u5408\u5e76<\/strong><\/h2>\n<p>result = list(itertools.chain(list3, list4))<\/p>\n<p>print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2a\u5217\u8868\uff0c\u5e76\u4f7f\u7528itertools.chain\u51fd\u6570\u5c06\u5b83\u4eec\u5408\u5e76\u6210\u4e00\u4e2a\u65b0\u7684\u5217\u8868\u3002\u7ed3\u679c\u662f\u4e00\u4e2a\u5305\u542b\u6240\u6709\u5143\u7d20\u7684\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528collections\u6a21\u5757\u4e2d\u7684defaultdict\u5408\u5e76\u6570\u636e<\/h4>\n<\/p>\n<p><p>defaultdict\u662fcollections\u6a21\u5757\u4e2d\u7684\u4e00\u79cd\u5b57\u5178\u5b50\u7c7b\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u9ed8\u8ba4\u503c\u5de5\u5382\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from collections import defaultdict<\/p>\n<h2><strong>\u521b\u5efa\u4e24\u4e2a\u5b57\u5178<\/strong><\/h2>\n<p>dict3 = {&#39;a&#39;: 1, &#39;b&#39;: 2}<\/p>\n<p>dict4 = {&#39;b&#39;: 3, &#39;c&#39;: 4}<\/p>\n<h2><strong>\u4f7f\u7528defaultdict\u5408\u5e76\u5b57\u5178<\/strong><\/h2>\n<p>result = defaultdict(int)<\/p>\n<p>for d in (dict3, dict4):<\/p>\n<p>    for key, value in d.items():<\/p>\n<p>        result[key] += value<\/p>\n<p>print(dict(result))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2a\u5b57\u5178\uff0c\u5e76\u4f7f\u7528defaultdict\u5c06\u5b83\u4eec\u5408\u5e76\u3002\u7ed3\u679c\u662f\u4e00\u4e2a\u65b0\u7684\u5b57\u5178\uff0c\u5305\u542b\u4e86\u4e24\u4e2a\u539f\u59cb\u5b57\u5178\u7684\u6240\u6709\u952e\u503c\u5bf9\uff0c\u5e76\u5bf9\u76f8\u540c\u952e\u7684\u503c\u8fdb\u884c\u4e86\u7d2f\u52a0\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u6570\u636e\u5408\u5e76\u7684\u5b9e\u9645\u5e94\u7528<\/h3>\n<\/p>\n<p><p>\u6570\u636e\u5408\u5e76\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u975e\u5e38\u5e38\u89c1\uff0c\u7279\u522b\u662f\u5728\u6570\u636e\u5206\u6790\u3001\u6570\u636e\u79d1\u5b66\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u4efb\u52a1\u4e2d\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5b9e\u9645\u5e94\u7528\u573a\u666f\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u5408\u5e76\u9500\u552e\u6570\u636e<\/h4>\n<\/p>\n<p><p>\u5047\u8bbe\u6211\u4eec\u6709\u4e24\u4e2aDataFrame\uff0c\u4e00\u4e2a\u5305\u542b\u9500\u552e\u8ba2\u5355\u4fe1\u606f\uff0c\u53e6\u4e00\u4e2a\u5305\u542b\u5ba2\u6237\u4fe1\u606f\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528merge\u65b9\u6cd5\u5c06\u8fd9\u4e24\u4e2aDataFrame\u5408\u5e76\uff0c\u4ee5\u4fbf\u5206\u6790\u6bcf\u4e2a\u5ba2\u6237\u7684\u9500\u552e\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u9500\u552e\u8ba2\u5355DataFrame<\/p>\n<p>orders = pd.DataFrame({<\/p>\n<p>    &#39;order_id&#39;: [1, 2, 3],<\/p>\n<p>    &#39;customer_id&#39;: [101, 102, 103],<\/p>\n<p>    &#39;amount&#39;: [250, 150, 300]<\/p>\n<p>})<\/p>\n<h2><strong>\u521b\u5efa\u5ba2\u6237\u4fe1\u606fDataFrame<\/strong><\/h2>\n<p>customers = pd.DataFrame({<\/p>\n<p>    &#39;customer_id&#39;: [101, 102, 103],<\/p>\n<p>    &#39;customer_name&#39;: [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;]<\/p>\n<p>})<\/p>\n<h2><strong>\u5408\u5e76\u9500\u552e\u8ba2\u5355\u548c\u5ba2\u6237\u4fe1\u606f<\/strong><\/h2>\n<p>result = pd.merge(orders, customers, on=&#39;customer_id&#39;)<\/p>\n<p>print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u9500\u552e\u8ba2\u5355\u548c\u5ba2\u6237\u4fe1\u606f\u4e24\u4e2aDataFrame\uff0c\u5e76\u4f7f\u7528merge\u65b9\u6cd5\u6839\u636e\u201ccustomer_id\u201d\u5217\u5c06\u5b83\u4eec\u5408\u5e76\u3002\u7ed3\u679c\u662f\u4e00\u4e2a\u65b0\u7684DataFrame\uff0c\u5305\u542b\u4e86\u6bcf\u4e2a\u8ba2\u5355\u7684\u8be6\u7ec6\u4fe1\u606f\u548c\u5ba2\u6237\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u5408\u5e76\u65f6\u95f4\u5e8f\u5217\u6570\u636e<\/h4>\n<\/p>\n<p><p>\u5047\u8bbe\u6211\u4eec\u6709\u4e24\u4e2a\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff0c\u4e00\u4e2a\u5305\u542b\u80a1\u7968\u4ef7\u683c\u4fe1\u606f\uff0c\u53e6\u4e00\u4e2a\u5305\u542b\u4ea4\u6613\u91cf\u4fe1\u606f\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528concat\u65b9\u6cd5\u5c06\u8fd9\u4e24\u4e2aDataFrame\u5408\u5e76\uff0c\u4ee5\u4fbf\u5206\u6790\u80a1\u7968\u4ef7\u683c\u548c\u4ea4\u6613\u91cf\u7684\u5173\u7cfb\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u80a1\u7968\u4ef7\u683cDataFrame<\/p>\n<p>prices = pd.DataFrame({<\/p>\n<p>    &#39;date&#39;: pd.date_range(start=&#39;2023-01-01&#39;, periods=5, freq=&#39;D&#39;),<\/p>\n<p>    &#39;price&#39;: [100, 102, 101, 103, 105]<\/p>\n<p>})<\/p>\n<h2><strong>\u521b\u5efa\u4ea4\u6613\u91cfDataFrame<\/strong><\/h2>\n<p>volumes = pd.DataFrame({<\/p>\n<p>    &#39;date&#39;: pd.date_range(start=&#39;2023-01-01&#39;, periods=5, freq=&#39;D&#39;),<\/p>\n<p>    &#39;volume&#39;: [200, 220, 210, 230, 240]<\/p>\n<p>})<\/p>\n<h2><strong>\u8bbe\u7f6e\u65e5\u671f\u4e3a\u7d22\u5f15<\/strong><\/h2>\n<p>prices.set_index(&#39;date&#39;, inplace=True)<\/p>\n<p>volumes.set_index(&#39;date&#39;, inplace=True)<\/p>\n<h2><strong>\u5408\u5e76\u80a1\u7968\u4ef7\u683c\u548c\u4ea4\u6613\u91cf<\/strong><\/h2>\n<p>result = pd.concat([prices, volumes], axis=1)<\/p>\n<p>print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u80a1\u7968\u4ef7\u683c\u548c\u4ea4\u6613\u91cf\u4e24\u4e2a\u65f6\u95f4\u5e8f\u5217DataFrame\uff0c\u5e76\u4f7f\u7528concat\u65b9\u6cd5\u5c06\u5b83\u4eec\u5408\u5e76\u3002\u7ed3\u679c\u662f\u4e00\u4e2a\u65b0\u7684DataFrame\uff0c\u5305\u542b\u4e86\u6bcf\u4e2a\u65e5\u671f\u7684\u80a1\u7968\u4ef7\u683c\u548c\u4ea4\u6613\u91cf\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u5408\u5e76\u6570\u636e\u7684\u6ce8\u610f\u4e8b\u9879<\/h3>\n<\/p>\n<p><p>\u5728\u5408\u5e76\u6570\u636e\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u6570\u636e\u6e05\u6d17<\/h4>\n<\/p>\n<p><p>\u5728\u5408\u5e76\u6570\u636e\u4e4b\u524d\uff0c\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u6e05\u6d17\uff0c\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u4e00\u81f4\u6027\u3002\u4f8b\u5982\uff0c\u5904\u7406\u7f3a\u5931\u503c\u3001\u53bb\u91cd\u3001\u6807\u51c6\u5316\u6570\u636e\u683c\u5f0f\u7b49\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u9009\u62e9\u5408\u9002\u7684\u5408\u5e76\u65b9\u5f0f<\/h4>\n<\/p>\n<p><p>\u6839\u636e\u6570\u636e\u7684\u7279\u70b9\u548c\u5206\u6790\u9700\u6c42\uff0c\u9009\u62e9\u5408\u9002\u7684\u5408\u5e76\u65b9\u5f0f\u3002\u4f8b\u5982\uff0c\u4f7f\u7528inner join\u3001left join\u3001right join\u6216outer join\uff0c\u9009\u62e9\u5408\u9002\u7684\u5408\u5e76\u952e\u7b49\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u5904\u7406\u91cd\u590d\u503c<\/h4>\n<\/p>\n<p><p>\u5728\u5408\u5e76\u6570\u636e\u65f6\uff0c\u5982\u679c\u51fa\u73b0\u91cd\u590d\u503c\uff0c\u9700\u8981\u6839\u636e\u5177\u4f53\u60c5\u51b5\u8fdb\u884c\u5904\u7406\u3002\u4f8b\u5982\uff0c\u5220\u9664\u91cd\u590d\u503c\u3001\u4fdd\u7559\u7b2c\u4e00\u4e2a\u6216\u6700\u540e\u4e00\u4e2a\u91cd\u590d\u503c\u3001\u5bf9\u91cd\u590d\u503c\u8fdb\u884c\u805a\u5408\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5904\u7406\u91cd\u590d\u503c\u793a\u4f8b<\/p>\n<p>data = pd.DataFrame({<\/p>\n<p>    &#39;id&#39;: [1, 1, 2, 2, 3],<\/p>\n<p>    &#39;value&#39;: [10, 10, 20, 20, 30]<\/p>\n<p>})<\/p>\n<h2><strong>\u5220\u9664\u91cd\u590d\u503c<\/strong><\/h2>\n<p>data_unique = data.drop_duplicates()<\/p>\n<p>print(data_unique)<\/p>\n<h2><strong>\u805a\u5408\u91cd\u590d\u503c<\/strong><\/h2>\n<p>data_agg = data.groupby(&#39;id&#39;).agg({&#39;value&#39;: &#39;sum&#39;}).reset_index()<\/p>\n<p>print(data_agg)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542b\u91cd\u590d\u503c\u7684DataFrame\uff0c\u5e76\u5206\u522b\u901a\u8fc7\u5220\u9664\u91cd\u590d\u503c\u548c\u805a\u5408\u91cd\u590d\u503c\u7684\u65b9\u6cd5\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u5408\u5e76\u5927\u6570\u636e\u96c6<\/h4>\n<\/p>\n<p><p>\u5728\u5904\u7406\u5927\u6570\u636e\u96c6\u65f6\uff0c\u5408\u5e76\u64cd\u4f5c\u53ef\u80fd\u4f1a\u5360\u7528\u5927\u91cf\u5185\u5b58\u548c\u8ba1\u7b97\u8d44\u6e90\u3002\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u5206\u5757\u5904\u7406\u3001\u5e76\u884c\u8ba1\u7b97\u7b49\u6280\u672f\u6765\u63d0\u9ad8\u6548\u7387\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5206\u5757\u5904\u7406\u793a\u4f8b<\/p>\n<p>chunk_size = 1000<\/p>\n<p>chunks = []<\/p>\n<p>for chunk in pd.read_csv(&#39;large_dataset.csv&#39;, chunksize=chunk_size):<\/p>\n<p>    # \u5bf9\u6bcf\u4e2a\u5757\u8fdb\u884c\u5904\u7406<\/p>\n<p>    chunk_processed = process_chunk(chunk)<\/p>\n<p>    chunks.append(chunk_processed)<\/p>\n<h2><strong>\u5408\u5e76\u5904\u7406\u540e\u7684\u5757<\/strong><\/h2>\n<p>result = pd.concat(chunks, ignore_index=True)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u5206\u5757\u5904\u7406\u7684\u65b9\u6cd5\u8bfb\u53d6\u548c\u5904\u7406\u4e00\u4e2a\u5927\u6570\u636e\u96c6\uff0c\u5e76\u5c06\u5904\u7406\u540e\u7684\u5757\u5408\u5e76\u6210\u4e00\u4e2a\u5b8c\u6574\u7684\u6570\u636e\u96c6\u3002<\/p>\n<\/p>\n<p><p>\u603b\u4e4b\uff0c\u5728Python\u4e2d\u5408\u5e76\u6570\u636e\u6709\u591a\u79cd\u65b9\u6cd5\u548c\u5de5\u5177\u53ef\u4f9b\u9009\u62e9\uff0c\u5177\u4f53\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\u53d6\u51b3\u4e8e\u6570\u636e\u7684\u7279\u70b9\u548c\u5206\u6790\u9700\u6c42\u3002\u901a\u8fc7\u5408\u7406\u9009\u62e9\u548c\u4f7f\u7528\u5408\u5e76\u65b9\u6cd5\uff0c\u53ef\u4ee5\u9ad8\u6548\u5730\u5904\u7406\u548c\u5206\u6790\u6570\u636e\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728Python\u4e2d\u5408\u5e76\u6570\u636e\u7684\u5e38\u7528\u65b9\u6cd5\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u5408\u5e76\u6570\u636e\u7684\u5e38\u7528\u65b9\u6cd5\u4e3b\u8981\u6709\u4f7f\u7528Pandas\u5e93\u7684<code>merge()<\/code>\u3001<code>concat()<\/code>\u548c<code>join()<\/code>\u51fd\u6570\u3002<code>merge()<\/code>\u51fd\u6570\u9002\u7528\u4e8e\u6839\u636e\u7279\u5b9a\u5217\u5408\u5e76\u6570\u636e\u6846\uff0c\u7c7b\u4f3c\u4e8eSQL\u4e2d\u7684JOIN\u64cd\u4f5c\uff1b<code>concat()<\/code>\u51fd\u6570\u5219\u7528\u4e8e\u5728\u884c\u6216\u5217\u4e0a\u8fde\u63a5\u591a\u4e2a\u6570\u636e\u6846\uff1b\u800c<code>join()<\/code>\u5219\u5e38\u7528\u4e8e\u57fa\u4e8e\u7d22\u5f15\u5408\u5e76\u3002\u6839\u636e\u9700\u6c42\u7684\u4e0d\u540c\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u5904\u7406\u6570\u636e\u3002<\/p>\n<p><strong>\u5408\u5e76\u6570\u636e\u65f6\u662f\u5426\u9700\u8981\u5904\u7406\u7f3a\u5931\u503c\uff1f<\/strong><br \/>\u5728\u5408\u5e76\u6570\u636e\u65f6\uff0c\u5904\u7406\u7f3a\u5931\u503c\u662f\u975e\u5e38\u91cd\u8981\u7684\u6b65\u9aa4\u3002\u7f3a\u5931\u503c\u53ef\u80fd\u4f1a\u5f71\u54cd\u5408\u5e76\u540e\u7684\u6570\u636e\u8d28\u91cf\u3002\u5982\u679c\u4e0d\u52a0\u5904\u7406\uff0c\u5408\u5e76\u540e\u7684\u7ed3\u679c\u53ef\u80fd\u4f1a\u51fa\u73b0NaN\u503c\u3002\u53ef\u4ee5\u5728\u5408\u5e76\u4e4b\u524d\u4f7f\u7528<code>fillna()<\/code>\u65b9\u6cd5\u586b\u5145\u7f3a\u5931\u503c\uff0c\u6216\u8005\u5728\u5408\u5e76\u540e\u5e94\u7528\u76f8\u5e94\u7684\u5904\u7406\u624b\u6bb5\uff0c\u4f8b\u5982\u5220\u9664\u5305\u542bNaN\u7684\u884c\u6216\u5217\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u5408\u5e76\u6570\u636e\u65f6\u907f\u514d\u91cd\u590d\u6570\u636e\uff1f<\/strong><br \/>\u4e3a\u4e86\u907f\u514d\u5728\u5408\u5e76\u6570\u636e\u65f6\u4ea7\u751f\u91cd\u590d\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>drop_duplicates()<\/code>\u65b9\u6cd5\u3002\u5408\u5e76\u524d\uff0c\u53ef\u4ee5\u5148\u68c0\u67e5\u5e76\u53bb\u9664\u91cd\u590d\u9879\uff0c\u786e\u4fdd\u5408\u5e76\u540e\u7684\u6570\u636e\u6846\u662f\u5e72\u51c0\u7684\u3002\u6b64\u5916\uff0c\u5728\u4f7f\u7528<code>merge()<\/code>\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e<code>how<\/code>\u53c2\u6570\u4e3a<code>inner<\/code>\u3001<code>outer<\/code>\u3001<code>left<\/code>\u6216<code>right<\/code>\u6765\u63a7\u5236\u5408\u5e76\u7684\u65b9\u5f0f\uff0c\u4ece\u800c\u51cf\u5c11\u91cd\u590d\u6570\u636e\u7684\u51fa\u73b0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u5408\u5e76\u6570\u636e\u7684\u5e38\u7528\u65b9\u6cd5\u6709\u4f7f\u7528pandas\u5e93\u3001\u4f7f\u7528numpy\u5e93\u3001\u4f7f\u7528\u5185\u7f6e\u7684zip\u51fd\u6570\u3001\u4f7f\u7528\u94fe\u8868\u548c\u5b57\u5178 [&hellip;]","protected":false},"author":3,"featured_media":1156314,"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\/1156308"}],"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=1156308"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1156308\/revisions"}],"predecessor-version":[{"id":1156315,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1156308\/revisions\/1156315"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1156314"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1156308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1156308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1156308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}