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

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

    In order to replace the NULL values with a given string I've used fill function present in Spark for Java. It accepts the word to be replaced with and a sequence of column names. Here is how I have implemented that:-

    List colList = new ArrayList();
    colList.add(cols[i]);
    Seq colSeq = scala.collection.JavaConverters.asScalaIteratorConverter(colList.iterator()).asScala().toSeq();
    data=data.na().fill(word, colSeq);
    

提交回复
热议问题