【pandas刷题系列】Leetcode Problem: [595. 大的国家]

编程入门 行业动态 更新时间:2024-10-25 19:25:28

【pandas刷题<a href=https://www.elefans.com/category/jswz/34/1770787.html style=系列】Leetcode Problem: [595. 大的国家]"/>

【pandas刷题系列】Leetcode Problem: [595. 大的国家]

Problem: 595. 大的国家

文章目录

  • 思路
  • 解题方法
  • 复杂度
  • Code

思路

筛选出对应的数据,然后将不需要的列去除

解题方法

筛选出对应的数据,然后将不需要的列去除

复杂度

  • 时间复杂度:

O ( n ) O(n) O(n)

  • 空间复杂度:

O ( n ) O(n) O(n)

Code

import pandas as pddef big_countries(world: pd.DataFrame) -> pd.DataFrame:return world[(world["area"] >= 3000000) | (world["population"] >= 25000000)].drop(columns=["continent","gdp"])

更多推荐

【pandas刷题系列】Leetcode Problem: [595. 大的国家]

本文发布于:2023-11-15 10:17:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598039.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:系列   国家   pandas   Leetcode   Problem

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!