masterDF = masterDF.na.fill(-1)
其它:
也可以在fill中使用Map,其中key是列名,value可以是Int, Long, Float, Double, String, Boolean.
masterDF.na.fill(masterDF.columns.map(_ -> false).toMap)
来自:
https://stackoverflow.com/questions/51073493/spark-dataframe-na-fill-boolean-column-type
* For example, the following replaces null values in column "A" with string "unknown", and
* null values in column "B" with numeric value 1.0.
* {{{
* df.na.fill(Map(
* "A" -> "unknown",
* "B" -> 1.0
* ))
* }}}
本文介绍如何使用Apache Spark中的DataFrame API来处理缺失值。通过具体的示例代码展示如何使用na.fill方法来替换指定列的null值。不仅可以为特定类型的列(如String或Numeric)设置默认值,还可以为Boolean类型的列进行缺失值填充。
6926

被折叠的 条评论
为什么被折叠?



