您现在的位置是:网站首页> 编程资料编程资料
pandas函数isnull的具体使用_python_
2023-05-26
487人已围观
简介 pandas函数isnull的具体使用_python_
一.假设有数据集df

df.isnull()
返回DateFrame,元素为空或者NA就显示True,否则就是False

二.判断有空值的列
df.isnull().any()
当列有为空或者NA的元素,就为True,否则False

三.显示出有空值列的列名的列表
df.columns[iris.isnull().any()].tolist()
四.删除全部是空值的行
df.dropna(axis=0,how='all',inplace=True)

五.删除全部是空值的列
df.dropna(axis=1,how='all',inplace=True)
六.对某一列中的空值进行填充
df['列名'].fillna(100,inplace= True)
七.method参数
method = ‘ffill’ : 是用每一列/行前面的值填充后面的空白
method = ‘bfill’: 是用每一列/行后面的值填充前面的空白
到此这篇关于pandas函数isnull的具体使用的文章就介绍到这了,更多相关pandas isnull内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
您可能感兴趣的文章:
相关内容
- 浅谈pandas关于查看库或依赖库版本的API原理_python_
- Python实现校园网自动登录的脚本分享_python_
- 浅析python中的set类型_python_
- pandas温差查询案例的实现_python_
- 基于Python实现本地音乐播放器的制作_python_
- Python读取CSV文件并进行数据可视化绘图_python_
- Python通过psd-tools解析PSD文件_python_
- 一文搞懂Pandas数据透视的4个函数的使用_python_
- python中ThreadPoolExecutor线程池和ProcessPoolExecutor进程池_python_
- Python+Pandas实现数据透视表_python_
