处理 Pandas 中的缺失数据 [英] handling missing data in Pandas

查看:45
本文介绍了处理 Pandas 中的缺失数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 200,000 x 500 dataframe 加载到 Pandas 中.是否有一个函数可以自动告诉我哪些列缺少数据?还是我必须遍历每一列并逐个元素检查?

I have a 200,000 x 500 dataframe loaded into Pandas. Is there a function that can automatically tell me which columns are missing data? Or do I have to iterate over each column and check element by element?

一旦发现缺失的元素,我该如何定义自定义函数(基于列名和同一行中的其他一些数据)来进行自动替换.我看到了 fillna() 方法,但我认为它不需要 (lambda) 函数作为输入.

Once I've found a missing element, how do I define a custom function (based on both the column name and some other data in the same row) to do automatic replacements. I see the fillna() method, but I don't think it takes a (lambda) function as an input.

谢谢!

推荐答案

类似于:

import pandas as pd
pd.isnull(frame).any()

可能是您寻找缺失数据的目的

Is probably what you're looking for to look for missing data

fillna 目前不接受 lambda 函数,尽管它在 github 上作为一个未解决的问题在工作中.

fillna currently does not take lambda functions though that's in the works as an open issue on github.

您现在可以使用 DataFrame.apply 进行自定义填充.但是,您能否更具体地说明填充数据所需的操作?只是好奇用例是什么.

You can use DataFrame.apply to do custom filling for now. Though can you be a little more specific on what you need to do to fill the data? Just curious what the use case is.

这篇关于处理 Pandas 中的缺失数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆