【发布时间】:2018-12-21 16:14:37
【问题描述】:
我有一个大型数据集,我想删除其中包含 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,因为其中一个值为空。
【问题讨论】:
标签: python apache-spark pyspark apache-spark-sql