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

后端 未结 4 657
抹茶落季
抹茶落季 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:43

    You'll want to use the fill(String value, String[] columns) method of your dataframe, which automatically replaces Null values in a given list of columns with the value you specified.

    So if you already know the value that you want to replace Null with...:

    String[] colNames = {"Name"}
    dataframe = dataframe.na.fill("a", colNames)
    

    You can do the same for the rest of your columns.

提交回复
热议问题