{"id":1151491,"date":"2025-01-13T17:14:13","date_gmt":"2025-01-13T09:14:13","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1151491.html"},"modified":"2025-01-13T17:14:16","modified_gmt":"2025-01-13T09:14:16","slug":"python%e5%a6%82%e4%bd%95%e6%9f%a5%e6%89%be%e6%95%b0%e6%8d%ae%e5%b7%ae%e5%bc%82","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1151491.html","title":{"rendered":"python\u5982\u4f55\u67e5\u627e\u6570\u636e\u5dee\u5f02"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25181728\/ed693a68-e71d-4d2f-96f6-22c2d27ca74e.webp\" alt=\"python\u5982\u4f55\u67e5\u627e\u6570\u636e\u5dee\u5f02\" \/><\/p>\n<p><p> \u5728Python\u4e2d\u67e5\u627e\u6570\u636e\u5dee\u5f02\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff0c<strong>\u5305\u62ec\u4f7f\u7528\u96c6\u5408\u64cd\u4f5c\u3001\u4f7f\u7528Pandas\u5e93\u7684\u6bd4\u8f83\u529f\u80fd\u3001\u4f7f\u7528difflib\u5e93\u8fdb\u884c\u6587\u672c\u6bd4\u8f83<\/strong>\u7b49\u3002<strong>\u4f7f\u7528Pandas\u5e93\u7684\u6bd4\u8f83\u529f\u80fd<\/strong>\u662f\u5176\u4e2d\u4e00\u79cd\u975e\u5e38\u5f3a\u5927\u4e14\u7075\u6d3b\u7684\u65b9\u6cd5\u3002Pandas\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u636e\u5206\u6790\u548c\u64cd\u4f5c\u5e93\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u51fd\u6570\u6765\u5904\u7406\u6570\u636e\uff0c\u5e76\u4e14\u7279\u522b\u9002\u5408\u5904\u7406\u7ed3\u6784\u5316\u6570\u636e\u3002<\/p>\n<\/p>\n<p><p>\u4e3e\u4e2a\u8be6\u7ec6\u7684\u4f8b\u5b50\uff0c\u5047\u8bbe\u6211\u4eec\u6709\u4e24\u4e2a\u6570\u636e\u8868\uff08DataFrame\uff09\uff0c\u6211\u4eec\u60f3\u627e\u51fa\u5b83\u4eec\u4e4b\u95f4\u7684\u5dee\u5f02\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e24\u4e2a\u793a\u4f8b\u6570\u636e\u8868<\/strong><\/h2>\n<p>df1 = pd.DataFrame({<\/p>\n<p>    &#39;id&#39;: [1, 2, 3],<\/p>\n<p>    &#39;value&#39;: [10, 20, 30]<\/p>\n<p>})<\/p>\n<p>df2 = pd.DataFrame({<\/p>\n<p>    &#39;id&#39;: [1, 2, 4],<\/p>\n<p>    &#39;value&#39;: [10, 25, 30]<\/p>\n<p>})<\/p>\n<h2><strong>\u4f7f\u7528Pandas\u7684merge\u51fd\u6570\u6765\u67e5\u627e\u5dee\u5f02<\/strong><\/h2>\n<p>merged_df = pd.merge(df1, df2, on=&#39;id&#39;, how=&#39;outer&#39;, suffixes=(&#39;_df1&#39;, &#39;_df2&#39;), indicator=True)<\/p>\n<p>diff_df = merged_df[merged_df[&#39;_merge&#39;] != &#39;both&#39;]<\/p>\n<p>print(diff_df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>merge<\/code>\u51fd\u6570\u5c06\u4e24\u4e2a\u6570\u636e\u8868\u5408\u5e76\uff0c\u5e76\u4f7f\u7528<code>indicator=True<\/code>\u53c2\u6570\u6765\u751f\u6210\u4e00\u4e2a\u6307\u793a\u5217\uff0c\u663e\u793a\u6bcf\u884c\u6570\u636e\u662f\u6765\u81ea\u54ea\u4e2a\u6570\u636e\u8868\u3002\u7136\u540e\u6211\u4eec\u7b5b\u9009\u51fa\u6307\u793a\u5217\u4e0d\u7b49\u4e8e&#39;both&#39;\u7684\u884c\uff0c\u8fd9\u4e9b\u884c\u5c31\u662f\u4e24\u4e2a\u6570\u636e\u8868\u4e2d\u7684\u5dee\u5f02\u3002<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u66f4\u8be6\u7ec6\u7684\u5185\u5bb9\uff0c\u4ecb\u7ecd\u67e5\u627e\u6570\u636e\u5dee\u5f02\u7684\u4e0d\u540c\u65b9\u6cd5\u548c\u5177\u4f53\u5e94\u7528\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u96c6\u5408\u64cd\u4f5c<\/h2>\n<\/p>\n<p><h3>1. \u4f7f\u7528\u96c6\u5408\u64cd\u4f5c\u67e5\u627e\u5dee\u5f02<\/h3>\n<\/p>\n<p><p>\u96c6\u5408\uff08Set\uff09\u662fPython\u4e2d\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u636e\u7ed3\u6784\uff0c\u652f\u6301\u8bb8\u591a\u6570\u5b66\u96c6\u5408\u64cd\u4f5c\uff0c\u6bd4\u5982\u5e76\u96c6\u3001\u4ea4\u96c6\u548c\u5dee\u96c6\u3002\u53ef\u4ee5\u4f7f\u7528\u96c6\u5408\u64cd\u4f5c\u6765\u67e5\u627e\u4e24\u4e2a\u6570\u636e\u96c6\u4e4b\u95f4\u7684\u5dee\u5f02\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">set1 = {1, 2, 3, 4, 5}<\/p>\n<p>set2 = {4, 5, 6, 7, 8}<\/p>\n<h2><strong>\u67e5\u627eset1\u4e0eset2\u7684\u5dee\u5f02<\/strong><\/h2>\n<p>difference = set1.symmetric_difference(set2)<\/p>\n<p>print(difference)  # \u8f93\u51fa: {1, 2, 3, 6, 7, 8}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>symmetric_difference<\/code>\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u96c6\u5408\uff0c\u5305\u542b\u5728set1\u6216set2\u4e2d\u4f46\u4e0d\u5728\u4e24\u8005\u4e2d\u7684\u5143\u7d20\u3002<\/p>\n<\/p>\n<p><h3>2. \u4f7f\u7528\u5217\u8868\u548c\u96c6\u5408\u67e5\u627e\u5dee\u5f02<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u6570\u636e\u662f\u5217\u8868\u5f62\u5f0f\uff0c\u53ef\u4ee5\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u96c6\u5408\uff0c\u7136\u540e\u4f7f\u7528\u96c6\u5408\u64cd\u4f5c\u67e5\u627e\u5dee\u5f02\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">list1 = [1, 2, 3, 4, 5]<\/p>\n<p>list2 = [4, 5, 6, 7, 8]<\/p>\n<h2><strong>\u8f6c\u6362\u4e3a\u96c6\u5408<\/strong><\/h2>\n<p>set1 = set(list1)<\/p>\n<p>set2 = set(list2)<\/p>\n<h2><strong>\u67e5\u627e\u5dee\u5f02<\/strong><\/h2>\n<p>difference = set1.symmetric_difference(set2)<\/p>\n<p>print(list(difference))  # \u8f93\u51fa: [1, 2, 3, 6, 7, 8]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u96c6\u5408\uff0c\u53ef\u4ee5\u5229\u7528\u96c6\u5408\u64cd\u4f5c\u7684\u9ad8\u6548\u6027\u548c\u7b80\u6d01\u6027\u6765\u67e5\u627e\u5dee\u5f02\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001Pandas\u5e93<\/h2>\n<\/p>\n<p><h3>1. \u4f7f\u7528Pandas\u7684<code>compare<\/code>\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>Pandas\u5e93\u63d0\u4f9b\u4e86\u4e00\u4e2a<code>compare<\/code>\u65b9\u6cd5\uff0c\u53ef\u4ee5\u76f4\u63a5\u6bd4\u8f83\u4e24\u4e2a\u6570\u636e\u8868\uff0c\u8fd4\u56de\u5b83\u4eec\u4e4b\u95f4\u7684\u5dee\u5f02\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e24\u4e2a\u793a\u4f8b\u6570\u636e\u8868<\/strong><\/h2>\n<p>df1 = pd.DataFrame({<\/p>\n<p>    &#39;id&#39;: [1, 2, 3],<\/p>\n<p>    &#39;value&#39;: [10, 20, 30]<\/p>\n<p>})<\/p>\n<p>df2 = pd.DataFrame({<\/p>\n<p>    &#39;id&#39;: [1, 2, 4],<\/p>\n<p>    &#39;value&#39;: [10, 25, 30]<\/p>\n<p>})<\/p>\n<h2><strong>\u4f7f\u7528compare\u65b9\u6cd5\u67e5\u627e\u5dee\u5f02<\/strong><\/h2>\n<p>diff = df1.compare(df2, keep_shape=True, keep_equal=True)<\/p>\n<p>print(diff)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>compare<\/code>\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u5dee\u5f02\u7684\u6570\u636e\u8868\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4f1a\u5ffd\u7565\u76f8\u540c\u7684\u884c\uff0c\u4f46\u53ef\u4ee5\u4f7f\u7528<code>keep_equal=True<\/code>\u53c2\u6570\u6765\u4fdd\u7559\u8fd9\u4e9b\u884c\u3002<\/p>\n<\/p>\n<p><h3>2. \u4f7f\u7528Pandas\u7684<code>merge<\/code>\u51fd\u6570<\/h3>\n<\/p>\n<p><p>\u524d\u9762\u63d0\u5230\u7684<code>merge<\/code>\u51fd\u6570\u4e5f\u662f\u4e00\u79cd\u975e\u5e38\u6709\u6548\u7684\u67e5\u627e\u5dee\u5f02\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e24\u4e2a\u793a\u4f8b\u6570\u636e\u8868<\/strong><\/h2>\n<p>df1 = pd.DataFrame({<\/p>\n<p>    &#39;id&#39;: [1, 2, 3],<\/p>\n<p>    &#39;value&#39;: [10, 20, 30]<\/p>\n<p>})<\/p>\n<p>df2 = pd.DataFrame({<\/p>\n<p>    &#39;id&#39;: [1, 2, 4],<\/p>\n<p>    &#39;value&#39;: [10, 25, 30]<\/p>\n<p>})<\/p>\n<h2><strong>\u4f7f\u7528merge\u51fd\u6570\u6765\u67e5\u627e\u5dee\u5f02<\/strong><\/h2>\n<p>merged_df = pd.merge(df1, df2, on=&#39;id&#39;, how=&#39;outer&#39;, suffixes=(&#39;_df1&#39;, &#39;_df2&#39;), indicator=True)<\/p>\n<p>diff_df = merged_df[merged_df[&#39;_merge&#39;] != &#39;both&#39;]<\/p>\n<p>print(diff_df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4f7f\u7528<code>merge<\/code>\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u5408\u5e76\u4e24\u4e2a\u6570\u636e\u8868\uff0c\u5e76\u4f7f\u7528\u6307\u793a\u5217\u6765\u627e\u51fa\u5dee\u5f02\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001difflib\u5e93<\/h2>\n<\/p>\n<p><h3>1. \u4f7f\u7528difflib\u5e93\u6bd4\u8f83\u6587\u672c<\/h3>\n<\/p>\n<p><p>difflib\u5e93\u662fPython\u6807\u51c6\u5e93\u7684\u4e00\u90e8\u5206\uff0c\u63d0\u4f9b\u4e86\u5f88\u591a\u7528\u4e8e\u6bd4\u8f83\u6587\u672c\u7684\u51fd\u6570\u548c\u7c7b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import difflib<\/p>\n<p>text1 = &quot;This is a simple text for comparison.&quot;<\/p>\n<p>text2 = &quot;This is a simple text for comparing.&quot;<\/p>\n<h2><strong>\u4f7f\u7528Differ\u7c7b\u6bd4\u8f83\u6587\u672c<\/strong><\/h2>\n<p>differ = difflib.Differ()<\/p>\n<p>diff = differ.compare(text1.split(), text2.split())<\/p>\n<h2><strong>\u6253\u5370\u51fa\u5dee\u5f02<\/strong><\/h2>\n<p>print(&#39;\\n&#39;.join(diff))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>Differ<\/code>\u7c7b\u7528\u4e8e\u6bd4\u8f83\u4e24\u4e2a\u6587\u672c\uff0c\u5e76\u751f\u6210\u4e00\u4e2a\u5305\u542b\u5dee\u5f02\u7684\u5217\u8868\u3002\u6bcf\u4e00\u884c\u90fd\u4ee5\u7279\u5b9a\u7684\u7b26\u53f7\u5f00\u5934\uff08\u4f8b\u5982\uff0c<code>-<\/code>\u8868\u793a\u5728\u7b2c\u4e00\u4e2a\u6587\u672c\u4e2d\u5b58\u5728\u4f46\u5728\u7b2c\u4e8c\u4e2a\u6587\u672c\u4e2d\u4e0d\u5b58\u5728\u7684\u884c\uff0c<code>+<\/code>\u8868\u793a\u5728\u7b2c\u4e8c\u4e2a\u6587\u672c\u4e2d\u5b58\u5728\u4f46\u5728\u7b2c\u4e00\u4e2a\u6587\u672c\u4e2d\u4e0d\u5b58\u5728\u7684\u884c\uff09\u3002<\/p>\n<\/p>\n<p><h3>2. \u4f7f\u7528HtmlDiff\u7c7b\u751f\u6210HTML\u5dee\u5f02<\/h3>\n<\/p>\n<p><p>difflib\u5e93\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a<code>HtmlDiff<\/code>\u7c7b\uff0c\u7528\u4e8e\u751f\u6210HTML\u683c\u5f0f\u7684\u5dee\u5f02\u62a5\u544a\uff0c\u9002\u5408\u5728\u7f51\u9875\u4e2d\u5c55\u793a\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import difflib<\/p>\n<p>text1 = &quot;This is a simple text for comparison.&quot;<\/p>\n<p>text2 = &quot;This is a simple text for comparing.&quot;<\/p>\n<h2><strong>\u4f7f\u7528HtmlDiff\u7c7b\u751f\u6210HTML\u5dee\u5f02<\/strong><\/h2>\n<p>html_diff = difflib.HtmlDiff().make_file(text1.split(), text2.split(), context=True)<\/p>\n<p>with open(&#39;diff.html&#39;, &#39;w&#39;) as f:<\/p>\n<p>    f.write(html_diff)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u751f\u6210\u7684HTML\u6587\u4ef6\u5c06\u663e\u793a\u4e24\u4e2a\u6587\u672c\u7684\u5dee\u5f02\uff0c\u5e76\u4ee5\u989c\u8272\u9ad8\u4eae\u7684\u65b9\u5f0f\u6807\u793a\u51fa\u6765\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u6570\u636e\u5dee\u5f02\u7684\u5b9e\u9645\u5e94\u7528<\/h2>\n<\/p>\n<p><h3>1. \u6570\u636e\u6e05\u6d17<\/h3>\n<\/p>\n<p><p>\u5728\u6570\u636e\u6e05\u6d17\u8fc7\u7a0b\u4e2d\uff0c\u67e5\u627e\u5e76\u5904\u7406\u6570\u636e\u5dee\u5f02\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u6b65\u9aa4\u3002\u901a\u8fc7\u6bd4\u8f83\u4e0d\u540c\u6570\u636e\u6e90\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u8bc6\u522b\u548c\u4fee\u590d\u6570\u636e\u4e2d\u7684\u9519\u8bef\u548c\u4e0d\u4e00\u81f4\u6027\u3002<\/p>\n<\/p>\n<p><h3>2. \u6570\u636e\u7248\u672c\u63a7\u5236<\/h3>\n<\/p>\n<p><p>\u5728\u6570\u636e\u5206\u6790\u548c\u6570\u636e\u79d1\u5b66\u9879\u76ee\u4e2d\uff0c\u6570\u636e\u7248\u672c\u63a7\u5236\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u5b9e\u8df5\u3002\u901a\u8fc7\u6bd4\u8f83\u4e0d\u540c\u7248\u672c\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u8ddf\u8e2a\u6570\u636e\u7684\u53d8\u5316\uff0c\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u4e00\u81f4\u6027\u3002<\/p>\n<\/p>\n<p><h3>3. \u6570\u636e\u5408\u5e76\u4e0e\u66f4\u65b0<\/h3>\n<\/p>\n<p><p>\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u65f6\uff0c\u7ecf\u5e38\u9700\u8981\u5c06\u591a\u4e2a\u6570\u636e\u6e90\u7684\u6570\u636e\u5408\u5e76\u6216\u66f4\u65b0\u4e3a\u4e00\u4e2a\u7edf\u4e00\u7684\u6570\u636e\u96c6\u3002\u901a\u8fc7\u67e5\u627e\u6570\u636e\u5dee\u5f02\uff0c\u53ef\u4ee5\u786e\u4fdd\u5408\u5e76\u548c\u66f4\u65b0\u64cd\u4f5c\u7684\u51c6\u786e\u6027\u3002<\/p>\n<\/p>\n<p><h3>4. \u6587\u672c\u6bd4\u8f83\u4e0e\u5408\u5e76<\/h3>\n<\/p>\n<p><p>\u6587\u672c\u6bd4\u8f83\u548c\u5408\u5e76\u5728\u8bb8\u591a\u5e94\u7528\u573a\u666f\u4e2d\u90fd\u5f88\u5e38\u89c1\uff0c\u4f8b\u5982\u4ee3\u7801\u7248\u672c\u63a7\u5236\u3001\u6587\u6863\u4fee\u8ba2\u548c\u534f\u4f5c\u7f16\u8f91\u3002\u901a\u8fc7\u67e5\u627e\u6587\u672c\u5dee\u5f02\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u7ba1\u7406\u548c\u5408\u5e76\u4e0d\u540c\u7248\u672c\u7684\u6587\u672c\u3002<\/p>\n<\/p>\n<p><h2>\u4e94\u3001\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u5728Python\u4e2d\u67e5\u627e\u6570\u636e\u5dee\u5f02\u7684\u65b9\u6cd5\u591a\u79cd\u591a\u6837\uff0c<strong>\u5305\u62ec\u4f7f\u7528\u96c6\u5408\u64cd\u4f5c\u3001Pandas\u5e93\u7684\u6bd4\u8f83\u529f\u80fd\u3001difflib\u5e93\u8fdb\u884c\u6587\u672c\u6bd4\u8f83<\/strong>\u7b49\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u7279\u5b9a\u7684\u5e94\u7528\u573a\u666f\u548c\u4f18\u7f3a\u70b9\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53ef\u4ee5\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u548c\u6570\u636e\u5904\u7406\u7684\u51c6\u786e\u6027\u3002\u901a\u8fc7\u638c\u63e1\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u5904\u7406\u548c\u5206\u6790\u6570\u636e\uff0c\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u6bd4\u8f83\u4e24\u4e2a\u6570\u636e\u96c6\u7684\u5dee\u5f02\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\u6765\u6bd4\u8f83\u4e24\u4e2a\u6570\u636e\u96c6\u7684\u5dee\u5f02\u3002\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528pandas\u5e93\u7684<code>merge<\/code>\u6216<code>concat<\/code>\u529f\u80fd\uff0c\u7ed3\u5408<code>drop_duplicates<\/code>\u6765\u67e5\u627e\u4e0d\u540c\u7684\u6570\u636e\u884c\u3002\u6b64\u5916\uff0cnumpy\u5e93\u4e5f\u53ef\u4ee5\u7528\u4e8e\u6bd4\u8f83\u6570\u7ec4\u95f4\u7684\u5dee\u5f02\u3002\u53ef\u4ee5\u6839\u636e\u9700\u8981\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u548c\u65b9\u6cd5\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\uff0c\u5982\u4f55\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u96c6\u7684\u5dee\u5f02\u6bd4\u8f83\uff1f<\/strong><br \/>\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u96c6\u65f6\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528pandas\u7684<code>DataFrame<\/code>\u5bf9\u8c61\u6765\u52a0\u8f7d\u548c\u5904\u7406\u6570\u636e\u3002\u901a\u8fc7\u4f7f\u7528<code>set_index<\/code>\u548c<code>join<\/code>\u7b49\u529f\u80fd\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u6bd4\u8f83\u548c\u627e\u51fa\u5dee\u5f02\u3002\u540c\u65f6\uff0c\u5229\u7528dask\u5e93\u53ef\u4ee5\u5904\u7406\u8d85\u51fa\u5185\u5b58\u7684\u6570\u636e\u96c6\uff0c\u786e\u4fdd\u5728\u5927\u6570\u636e\u73af\u5883\u4e0b\u7684\u9ad8\u6548\u6bd4\u8f83\u3002<\/p>\n<p><strong>\u5982\u4f55\u53ef\u89c6\u5316Python\u4e2d\u7684\u6570\u636e\u5dee\u5f02\uff1f<\/strong><br \/>\u53ef\u89c6\u5316\u6570\u636e\u5dee\u5f02\u53ef\u4ee5\u4f7f\u7528matplotlib\u6216seaborn\u7b49\u5e93\u3002\u901a\u8fc7\u7ed8\u5236\u67f1\u72b6\u56fe\u6216\u70ed\u56fe\uff0c\u80fd\u591f\u76f4\u89c2\u5c55\u793a\u4e24\u4e2a\u6570\u636e\u96c6\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u6b64\u5916\uff0c\u4f7f\u7528\u6563\u70b9\u56fe\u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u6570\u636e\u5206\u5e03\u7684\u53d8\u5316\uff0c\u589e\u5f3a\u5206\u6790\u7684\u76f4\u89c2\u6027\u548c\u7406\u89e3\u5ea6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u67e5\u627e\u6570\u636e\u5dee\u5f02\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff0c\u5305\u62ec\u4f7f\u7528\u96c6\u5408\u64cd\u4f5c\u3001\u4f7f\u7528Pandas\u5e93\u7684\u6bd4\u8f83\u529f\u80fd\u3001\u4f7f\u7528difflib\u5e93 [&hellip;]","protected":false},"author":3,"featured_media":1151495,"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\/1151491"}],"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=1151491"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1151491\/revisions"}],"predecessor-version":[{"id":1151498,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1151491\/revisions\/1151498"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1151495"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1151491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1151491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1151491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}