Вы можете использовать Map
внутри fill
, где ключ - имя столбца и значение имеет значение Int
, Long
, Float
, Double
String
1012
masterDF.na.fill(masterDF.columns.map(_ -> false).toMap)
Документ API гласит:
/**
* (Scala-specific) Returns a new `DataFrame` that replaces null values.
*
* The key of the map is the column name, and the value of the map is the replacement value.
* The value must be of the following type: `Int`, `Long`, `Float`, `Double`, `String`, `Boolean`.
* Replacement values are cast to the column data 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
* ))
* }}}
*
* @since 1.3.1
*/
def fill(valueMap: Map[String, Any]): DataFrame = fillMap(valueMap.toSeq)
Вы можете даже установить разные значения для разных столбцов, используя Map
внутри функции fill
.
Надеюсь, ответ полезен.