Python/Pyspark - 计数 NULL、空和 NaN [英] Python / Pyspark - Count NULL, empty and NaN

查看:56
本文介绍了Python/Pyspark - 计数 NULL、空和 NaN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算列中的 NULL、空值和 NaN 值.我是这样试的:

i want to count NULL, empty and NaN values in a column. I tried it like this:

df.filter( (df["ID"] == "") | (df["ID"].isNull()) | ( df["ID"].isnan()) ).count()

但我总是收到此错误消息:

But i always get this error message:

TypeError: 'Column' object is not callable

有人知道可能是什么问题吗?

Does anyone have an idea what might be the problem?

非常感谢!

推荐答案

isnan 不是属于 Column 类的方法,需要导入:

isnan is not a method belonging to the Column class, you need to import it:

from pyspark.sql.functions import isnan

并像这样使用它:

df.filter((df["ID"] == "") | df["ID"].isNull() | isnan(df["ID"])).count()

这篇关于Python/Pyspark - 计数 NULL、空和 NaN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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