How to replace null values with a specific value in Dataframe using spark in Java?

后端 未结 4 656
抹茶落季
抹茶落季 2020-12-05 14:00

I am trying improve the accuracy of Logistic regression algorithm implemented in Spark using Java. For this I\'m trying to replace Null or invalid values present in a column

4条回答
  •  清歌不尽
    2020-12-05 14:42

    You can use DataFrame.na.fill() to replace the null with some value To update at once you can do as

    val map = Map("Name" -> "a", "Place" -> "a2")
    
    df.na.fill(map).show()
    

    But if you want to replace a bad record too then you need to validate the bad records first. You can do this by using regular expression with like function.

提交回复
热议问题