0

I am trying to replace or update some specific column value in dataframe, as we know Dataframe is immutable, I am trying to transform in to new dataframe instead of Update or Replacement.

I tried dataframe.replace as explained in Spark doc, but it's giving me error as error: value replace is not a member of org.apache.spark.sql.DataFrame

I tried below option.For passing multiple value I am passing in array

val new_df= df.replace("Stringcolumn", Map(array("11","17","18","10"->"12")))

but I am getting error as

error: overloaded method value array with alternatives

Help is really appreciated!!

1 Answer 1

1

To access org.apache.spark.sql.DataFrameNaFunctions such as replace you have to call .na. So your code should look something like this,

import com.google.common.collect.ImmutableMap

df.na.replace("Stringcolumn", Map(10 -> 12, 11 -> 17))

see here to get all the list of DataFrameNaFunctions and how to use them

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.