{"id":1136724,"date":"2025-01-08T21:39:21","date_gmt":"2025-01-08T13:39:21","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1136724.html"},"modified":"2025-01-08T21:39:23","modified_gmt":"2025-01-08T13:39:23","slug":"python%e5%a6%82%e4%bd%95%e5%9c%a8%e5%8c%ba%e9%97%b4%e9%87%8c%e7%bb%9f%e8%ae%a1%e6%95%b0%e5%ad%97%e7%9a%84%e4%b8%aa%e6%95%b0","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1136724.html","title":{"rendered":"python\u5982\u4f55\u5728\u533a\u95f4\u91cc\u7edf\u8ba1\u6570\u5b57\u7684\u4e2a\u6570"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25100740\/4bc1ffe8-9f3e-4f97-ba28-3ed9d4e39d33.webp\" alt=\"python\u5982\u4f55\u5728\u533a\u95f4\u91cc\u7edf\u8ba1\u6570\u5b57\u7684\u4e2a\u6570\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\u7edf\u8ba1\u533a\u95f4\u5185\u7684\u6570\u5b57\u4e2a\u6570\uff0c\u5982\u5faa\u73af\u904d\u5386\u3001\u5217\u8868\u89e3\u6790\u3001\u5185\u7f6e\u51fd\u6570\u7b49\u3002<\/strong><\/p>\n<\/p>\n<p><p><strong>\u5faa\u73af\u904d\u5386\u3001\u5217\u8868\u89e3\u6790\u3001\u5185\u7f6e\u51fd\u6570<\/strong>\u662f\u4e09\u79cd\u5e38\u89c1\u7684\u65b9\u6cd5\u3002\u4e0b\u9762\u6211\u4eec\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u4e00\u79cd\uff1a\u5faa\u73af\u904d\u5386\u3002\u5faa\u73af\u904d\u5386\u662f\u4e00\u79cd\u8f83\u4e3a\u76f4\u89c2\u4e14\u6613\u4e8e\u7406\u89e3\u7684\u65b9\u6cd5\uff0c\u901a\u8fc7\u904d\u5386\u6574\u4e2a\u5217\u8868\uff0c\u7136\u540e\u5224\u65ad\u6bcf\u4e2a\u5143\u7d20\u662f\u5426\u5728\u7ed9\u5b9a\u7684\u533a\u95f4\u5185\uff0c\u5982\u679c\u5728\uff0c\u5219\u8ba1\u6570\u5668\u52a0\u4e00\u3002\u8fd9\u6837\u6211\u4eec\u5c31\u80fd\u7edf\u8ba1\u51fa\u533a\u95f4\u5185\u6570\u5b57\u7684\u4e2a\u6570\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5faa\u73af\u904d\u5386<\/h3>\n<\/p>\n<p><p>\u5faa\u73af\u904d\u5386\u662f\u4e00\u79cd\u6700\u57fa\u672c\u7684\u65b9\u6cd5\uff0c\u901a\u8fc7\u904d\u5386\u6574\u4e2a\u5217\u8868\u6216\u6570\u7ec4\uff0c\u9010\u4e2a\u68c0\u67e5\u6bcf\u4e2a\u6570\u5b57\u662f\u5426\u5728\u6307\u5b9a\u7684\u533a\u95f4\u5185\uff0c\u7136\u540e\u8ba1\u6570\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def count_numbers_in_range(lst, start, end):<\/p>\n<p>    count = 0<\/p>\n<p>    for num in lst:<\/p>\n<p>        if start &lt;= num &lt;= end:<\/p>\n<p>            count += 1<\/p>\n<p>    return count<\/p>\n<h2><strong>\u793a\u4f8b\u5217\u8868<\/strong><\/h2>\n<p>numbers = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]<\/p>\n<h2><strong>\u533a\u95f4 [4, 8]<\/strong><\/h2>\n<p>result = count_numbers_in_range(numbers, 4, 8)<\/p>\n<p>print(result)  # \u8f93\u51fa: 4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u51fd\u6570 <code>count_numbers_in_range<\/code>\uff0c\u5b83\u63a5\u53d7\u4e00\u4e2a\u5217\u8868 <code>lst<\/code> \u548c\u533a\u95f4\u7684\u5f00\u59cb\u548c\u7ed3\u675f\u503c <code>start<\/code> \u548c <code>end<\/code>\u3002\u51fd\u6570\u901a\u8fc7\u904d\u5386\u5217\u8868\uff0c\u68c0\u67e5\u6bcf\u4e2a\u6570\u5b57\u662f\u5426\u5728\u533a\u95f4\u5185\uff0c\u5e76\u8ba1\u6570\u7b26\u5408\u6761\u4ef6\u7684\u6570\u5b57\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5217\u8868\u89e3\u6790<\/h3>\n<\/p>\n<p><p>\u5217\u8868\u89e3\u6790\u662f\u4e00\u79cd\u66f4\u52a0\u7b80\u6d01\u548cPythonic\u7684\u65b9\u6cd5\uff0c\u901a\u8fc7\u4e00\u884c\u4ee3\u7801\u5c31\u80fd\u5b9e\u73b0\u540c\u6837\u7684\u529f\u80fd\u3002\u5217\u8868\u89e3\u6790\u5728\u5904\u7406\u8f83\u5c0f\u7684\u6570\u636e\u96c6\u65f6\u6548\u7387\u8f83\u9ad8\uff0c\u4e14\u4ee3\u7801\u53ef\u8bfb\u6027\u66f4\u5f3a\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u5217\u8868\u89e3\u6790\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def count_numbers_in_range(lst, start, end):<\/p>\n<p>    return len([num for num in lst if start &lt;= num &lt;= end])<\/p>\n<h2><strong>\u793a\u4f8b\u5217\u8868<\/strong><\/h2>\n<p>numbers = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]<\/p>\n<h2><strong>\u533a\u95f4 [4, 8]<\/strong><\/h2>\n<p>result = count_numbers_in_range(numbers, 4, 8)<\/p>\n<p>print(result)  # \u8f93\u51fa: 4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u5217\u8868\u89e3\u6790\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u5217\u8868\uff0c\u5305\u542b\u6240\u6709\u5728\u533a\u95f4\u5185\u7684\u6570\u5b57\uff0c\u7136\u540e\u901a\u8fc7 <code>len<\/code> \u51fd\u6570\u83b7\u53d6\u8be5\u5217\u8868\u7684\u957f\u5ea6\uff0c\u5373\u4e3a\u533a\u95f4\u5185\u6570\u5b57\u7684\u4e2a\u6570\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5185\u7f6e\u51fd\u6570<\/h3>\n<\/p>\n<p><p>Python\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5185\u7f6e\u51fd\u6570\u548c\u6a21\u5757\uff0c\u53ef\u4ee5\u7528\u6765\u7b80\u5316\u7edf\u8ba1\u533a\u95f4\u5185\u6570\u5b57\u4e2a\u6570\u7684\u4efb\u52a1\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>filter<\/code> \u51fd\u6570\u7ed3\u5408 <code>lambda<\/code> \u8868\u8fbe\u5f0f\u6765\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def count_numbers_in_range(lst, start, end):<\/p>\n<p>    return len(list(filter(lambda x: start &lt;= x &lt;= end, lst)))<\/p>\n<h2><strong>\u793a\u4f8b\u5217\u8868<\/strong><\/h2>\n<p>numbers = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]<\/p>\n<h2><strong>\u533a\u95f4 [4, 8]<\/strong><\/h2>\n<p>result = count_numbers_in_range(numbers, 4, 8)<\/p>\n<p>print(result)  # \u8f93\u51fa: 4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 <code>filter<\/code> \u51fd\u6570\u8fc7\u6ee4\u51fa\u6240\u6709\u5728\u533a\u95f4\u5185\u7684\u6570\u5b57\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u5217\u8868\uff0c\u6700\u540e\u901a\u8fc7 <code>len<\/code> \u51fd\u6570\u83b7\u53d6\u5217\u8868\u7684\u957f\u5ea6\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001Numpy\u5e93<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\uff0c\u4f7f\u7528 <code>numpy<\/code> \u5e93\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u6027\u80fd\u3002 <code>numpy<\/code> \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u79d1\u5b66\u8ba1\u7b97\u5e93\uff0c\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u6570\u7ec4\u64cd\u4f5c\u529f\u80fd\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528 <code>numpy<\/code> \u5e93\u7edf\u8ba1\u533a\u95f4\u5185\u6570\u5b57\u4e2a\u6570\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>def count_numbers_in_range(lst, start, end):<\/p>\n<p>    arr = np.array(lst)<\/p>\n<p>    return np.sum((arr &gt;= start) &amp; (arr &lt;= end))<\/p>\n<h2><strong>\u793a\u4f8b\u5217\u8868<\/strong><\/h2>\n<p>numbers = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]<\/p>\n<h2><strong>\u533a\u95f4 [4, 8]<\/strong><\/h2>\n<p>result = count_numbers_in_range(numbers, 4, 8)<\/p>\n<p>print(result)  # \u8f93\u51fa: 4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u5217\u8868\u8f6c\u6362\u4e3a <code>numpy<\/code> \u6570\u7ec4\uff0c\u7136\u540e\u4f7f\u7528\u5e03\u5c14\u7d22\u5f15\u6765\u7b5b\u9009\u51fa\u5728\u533a\u95f4\u5185\u7684\u6570\u5b57\uff0c\u6700\u540e\u901a\u8fc7 <code>np.sum<\/code> \u51fd\u6570\u8ba1\u7b97\u5e03\u5c14\u6570\u7ec4\u4e2d <code>True<\/code> \u7684\u4e2a\u6570\uff0c\u5373\u4e3a\u533a\u95f4\u5185\u6570\u5b57\u7684\u4e2a\u6570\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001Pandas\u5e93<\/h3>\n<\/p>\n<p><p><code>pandas<\/code> \u5e93\u662f\u53e6\u4e00\u4e2a\u5904\u7406\u6570\u636e\u7684\u5f3a\u5927\u5de5\u5177\uff0c\u7279\u522b\u9002\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 <code>pandas<\/code> \u5e93\u4e2d\u7684 <code>Series<\/code> \u5bf9\u8c61\u6765\u7edf\u8ba1\u533a\u95f4\u5185\u6570\u5b57\u4e2a\u6570\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>def count_numbers_in_range(lst, start, end):<\/p>\n<p>    series = pd.Series(lst)<\/p>\n<p>    return series.between(start, end).sum()<\/p>\n<h2><strong>\u793a\u4f8b\u5217\u8868<\/strong><\/h2>\n<p>numbers = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]<\/p>\n<h2><strong>\u533a\u95f4 [4, 8]<\/strong><\/h2>\n<p>result = count_numbers_in_range(numbers, 4, 8)<\/p>\n<p>print(result)  # \u8f93\u51fa: 4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u5217\u8868\u8f6c\u6362\u4e3a <code>pandas<\/code> \u7684 <code>Series<\/code> \u5bf9\u8c61\uff0c\u7136\u540e\u4f7f\u7528 <code>between<\/code> \u65b9\u6cd5\u7b5b\u9009\u51fa\u5728\u533a\u95f4\u5185\u7684\u6570\u5b57\uff0c\u6700\u540e\u901a\u8fc7 <code>sum<\/code> \u65b9\u6cd5\u8ba1\u7b97\u5e03\u5c14\u6570\u7ec4\u4e2d <code>True<\/code> \u7684\u4e2a\u6570\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u6027\u80fd\u6bd4\u8f83<\/h3>\n<\/p>\n<p><p>\u4e0d\u540c\u65b9\u6cd5\u5728\u5904\u7406\u4e0d\u540c\u89c4\u6a21\u7684\u6570\u636e\u65f6\u6027\u80fd\u53ef\u80fd\u4f1a\u6709\u6240\u4e0d\u540c\u3002\u4ee5\u4e0b\u662f\u5bf9\u4e0a\u8ff0\u51e0\u79cd\u65b9\u6cd5\u7684\u6027\u80fd\u6bd4\u8f83\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import time<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5927\u5217\u8868<\/strong><\/h2>\n<p>large_list = list(range(1000000))<\/p>\n<h2><strong>\u5b9a\u4e49\u533a\u95f4<\/strong><\/h2>\n<p>start, end = 100, 10000<\/p>\n<h2><strong>\u6d4b\u8bd5\u5faa\u73af\u904d\u5386<\/strong><\/h2>\n<p>start_time = time.time()<\/p>\n<p>count_numbers_in_range(large_list, start, end)<\/p>\n<p>end_time = time.time()<\/p>\n<p>print(f&quot;\u5faa\u73af\u904d\u5386\u8017\u65f6: {end_time - start_time:.6f} \u79d2&quot;)<\/p>\n<h2><strong>\u6d4b\u8bd5\u5217\u8868\u89e3\u6790<\/strong><\/h2>\n<p>start_time = time.time()<\/p>\n<p>count_numbers_in_range(large_list, start, end)<\/p>\n<p>end_time = time.time()<\/p>\n<p>print(f&quot;\u5217\u8868\u89e3\u6790\u8017\u65f6: {end_time - start_time:.6f} \u79d2&quot;)<\/p>\n<h2><strong>\u6d4b\u8bd5\u5185\u7f6e\u51fd\u6570<\/strong><\/h2>\n<p>start_time = time.time()<\/p>\n<p>count_numbers_in_range(large_list, start, end)<\/p>\n<p>end_time = time.time()<\/p>\n<p>print(f&quot;\u5185\u7f6e\u51fd\u6570\u8017\u65f6: {end_time - start_time:.6f} \u79d2&quot;)<\/p>\n<h2><strong>\u6d4b\u8bd5Numpy<\/strong><\/h2>\n<p>start_time = time.time()<\/p>\n<p>count_numbers_in_range(large_list, start, end)<\/p>\n<p>end_time = time.time()<\/p>\n<p>print(f&quot;Numpy \u8017\u65f6: {end_time - start_time:.6f} \u79d2&quot;)<\/p>\n<h2><strong>\u6d4b\u8bd5Pandas<\/strong><\/h2>\n<p>start_time = time.time()<\/p>\n<p>count_numbers_in_range(large_list, start, end)<\/p>\n<p>end_time = time.time()<\/p>\n<p>print(f&quot;Pandas \u8017\u65f6: {end_time - start_time:.6f} \u79d2&quot;)<\/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\u4e00\u767e\u4e07\u4e2a\u6570\u5b57\u7684\u5927\u5217\u8868\uff0c\u5e76\u6d4b\u8bd5\u4e86\u4e0d\u540c\u65b9\u6cd5\u5728\u7edf\u8ba1\u533a\u95f4\u5185\u6570\u5b57\u4e2a\u6570\u65f6\u7684\u6027\u80fd\u3002\u7ed3\u679c\u4f1a\u56e0\u673a\u5668\u548c\u73af\u5883\u7684\u4e0d\u540c\u800c\u6709\u6240\u5dee\u5f02\uff0c\u4f46\u901a\u5e38\u6765\u8bf4\uff0c<code>numpy<\/code> \u548c <code>pandas<\/code> \u7684\u6027\u80fd\u4f1a\u4f18\u4e8e\u5176\u4ed6\u65b9\u6cd5\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\u65f6\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u7edf\u8ba1\u533a\u95f4\u5185\u6570\u5b57\u4e2a\u6570\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff0c\u5305\u62ec\u5faa\u73af\u904d\u5386\u3001\u5217\u8868\u89e3\u6790\u3001\u5185\u7f6e\u51fd\u6570\u3001<code>numpy<\/code> \u5e93\u548c <code>pandas<\/code> \u5e93\u3002\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\u53d6\u51b3\u4e8e\u6570\u636e\u96c6\u7684\u89c4\u6a21\u548c\u5177\u4f53\u9700\u6c42\u3002\u5bf9\u4e8e\u8f83\u5c0f\u7684\u6570\u636e\u96c6\uff0c\u5faa\u73af\u904d\u5386\u548c\u5217\u8868\u89e3\u6790\u662f\u7b80\u5355\u4e14\u6613\u4e8e\u7406\u89e3\u7684\u65b9\u6cd5\u3002\u800c\u5bf9\u4e8e\u5927\u578b\u6570\u636e\u96c6\uff0c\u4f7f\u7528 <code>numpy<\/code> \u548c <code>pandas<\/code> \u5e93\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><p>\u65e0\u8bba\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\uff0c\u5173\u952e\u662f\u8981\u4e86\u89e3\u5176\u4f18\u7f3a\u70b9\uff0c\u5e76\u6839\u636e\u5177\u4f53\u60c5\u51b5\u8fdb\u884c\u9009\u62e9\u3002\u901a\u8fc7\u5bf9\u4e0d\u540c\u65b9\u6cd5\u7684\u7406\u89e3\u548c\u5e94\u7528\uff0c\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u89e3\u51b3\u7edf\u8ba1\u533a\u95f4\u5185\u6570\u5b57\u4e2a\u6570\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u7edf\u8ba1\u6307\u5b9a\u533a\u95f4\u5185\u7684\u6570\u5b57\u4e2a\u6570\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u5217\u8868\u63a8\u5bfc\u5f0f\u6216\u4f7f\u7528filter\u51fd\u6570\u6765\u7edf\u8ba1\u4e00\u4e2a\u5217\u8868\u4e2d\u7b26\u5408\u7279\u5b9a\u6761\u4ef6\u7684\u6570\u5b57\u4e2a\u6570\u3002\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\uff0c\u4f20\u5165\u9700\u8981\u7edf\u8ba1\u7684\u6570\u5b57\u5217\u8868\u548c\u533a\u95f4\uff0c\u7136\u540e\u8fd4\u56de\u7b26\u5408\u6761\u4ef6\u7684\u6570\u5b57\u6570\u91cf\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u6709\u54ea\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u9ad8\u6548\u5730\u7edf\u8ba1\u6570\u5b57\u4e2a\u6570\uff1f<\/strong><br \/>\u9664\u4e86\u4f7f\u7528\u7b80\u5355\u7684\u5217\u8868\u63a8\u5bfc\u5f0f\u5916\uff0cNumPy\u5e93\u63d0\u4f9b\u4e86\u66f4\u9ad8\u6548\u7684\u65b9\u6cd5\u6765\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u3002\u4f7f\u7528NumPy\u7684\u6761\u4ef6\u7b5b\u9009\uff0c\u53ef\u4ee5\u5feb\u901f\u83b7\u53d6\u6307\u5b9a\u533a\u95f4\u5185\u7684\u5143\u7d20\u4e2a\u6570\u3002\u6b64\u5916\uff0cPandas\u5e93\u4e5f\u9002\u7528\u4e8e\u6b64\u7c7b\u7edf\u8ba1\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u6570\u636e\u6846\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528DataFrame\u7684\u6761\u4ef6\u8fc7\u6ee4\u529f\u80fd\u3002<\/p>\n<p><strong>\u5728\u533a\u95f4\u7edf\u8ba1\u6570\u5b57\u65f6\uff0c\u5982\u4f55\u5904\u7406\u8fb9\u754c\u503c\uff1f<\/strong><br \/>\u5728\u8fdb\u884c\u7edf\u8ba1\u65f6\uff0c\u9700\u8981\u51b3\u5b9a\u662f\u5426\u5c06\u533a\u95f4\u7684\u8fb9\u754c\u503c\u5305\u542b\u5728\u5185\u3002\u8fd9\u901a\u5e38\u53d6\u51b3\u4e8e\u5177\u4f53\u9700\u6c42\u3002\u53ef\u4ee5\u4f7f\u7528&lt;=\u548c&gt;=\u64cd\u4f5c\u7b26\u6765\u63a7\u5236\u8fb9\u754c\u503c\u7684\u5305\u542b\uff0c\u6216\u8005\u6839\u636e\u5177\u4f53\u60c5\u51b5\u8c03\u6574\u903b\u8f91\uff0c\u4ee5\u786e\u4fdd\u7edf\u8ba1\u7ed3\u679c\u7b26\u5408\u9884\u671f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\u7edf\u8ba1\u533a\u95f4\u5185\u7684\u6570\u5b57\u4e2a\u6570\uff0c\u5982\u5faa\u73af\u904d\u5386\u3001\u5217\u8868\u89e3\u6790\u3001\u5185\u7f6e\u51fd\u6570\u7b49\u3002 \u5faa\u73af\u904d\u5386\u3001\u5217\u8868\u89e3\u6790 [&hellip;]","protected":false},"author":3,"featured_media":1136732,"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\/1136724"}],"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=1136724"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1136724\/revisions"}],"predecessor-version":[{"id":1136733,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1136724\/revisions\/1136733"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1136732"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1136724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1136724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1136724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}