我是靠谱客的博主 舒心小猫咪,这篇文章主要介绍Python pandas找出空值的行,现在分享给大家,希望可以做个参考。

import pandas as pd
import numpy as np
     
n = np.arange(20, dtype=float).reshape(5,4)

n[2,3] = np.nan
index = ['index1', 'index2', 'index3', 'index4', 'index5']
columns = ['column1', 'column2', 'column3', 'column4']
frame3 = pd.DataFrame(data=n, index=index, columns=columns)
print(frame3[frame3.isnull().T.any()])
# 找到空值对应的行与列

在这里插入图片描述

非转置:frame3.isnull().any(),得到的每一列求any()计算的结果,输出为列的Series。
转置:frame3.isnull().T.any(),得到的每一行求any()计算的结果,输出为行的Series。

最后

以上就是舒心小猫咪最近收集整理的关于Python pandas找出空值的行的全部内容,更多相关Python内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(66)

评论列表共有 0 条评论

立即
投稿
返回
顶部