美文网首页
Pandas实战——DataFrame操作

Pandas实战——DataFrame操作

作者: 深思海数_willschang | 来源:发表于2021-09-11 14:59 被阅读0次
pandas in action.png

原书地址

本篇笔记为原书第五章节的内容。

  • Flitering a DataFrame

DataFrame数据优化(内存优化)

主要就是对一些数据类型进行变换,如

  • 字符串转为布尔型
  • 类别型转为数字型
  • 缺失值处理再类型转换等
  • 浮点型数值转为整数型

单条件获取数据

==.png
!= / >.png

多条件提取数据

We can filter a DataFrame with multiple conditions by creating two independent Boolean Series and then declaring the logical criterion that pandas should apply between them.

逻辑条件

条件过滤

  • isin()


    isin()
  • between()


    between()
    between()
  • isnull() # 某列中各个值是否为空

  • notnull()

  • dropna() # 丢弃掉空值,how参数(all, any),subset参数(指定某列),thresh参数(阈值,几个空值)


    dropna()

重复值操作

  • df['col'].duplicated() # col列中各个值是否为重复值,keep参数(first,last)重复值首次(最后)出现为真,其他地方出现为假
  • drop_duplicates() # 去重,subset参数(指定列),keep参数(first,last)


    drop_duplicates()

相关文章

网友评论

      本文标题:Pandas实战——DataFrame操作

      本文链接:https://www.haomeiwen.com/subject/amagwltx.html