我有一个大型数据集,我想删除包含
null
值的列,并返回一个新的数据框。我该如何做到这一点?下面的代码只能删除一个包含null
值的列或行。df.where(col("dt_mvmt").isNull()) #doesnt work because I do not have all the columns names or for 1000's of columns
df.filter(df.dt_mvmt.isNotNull()) #same reason as above
df.na.drop() #drops rows that contain null, instead of columns that contain null
例如a | b | c
1 | | 0
2 | 2 | 3
在上述情况下,它将删除整个列B
,因为它的一个值为空。