Skip to content
Advertisement

How do I specify a default value when the value is “null” in a spark dataframe?

I have a data frame like the picture below.

enter image description here

In the case of “null” among the values of the “item_param” column, I want to replace the string’test’. How can I do it?

enter image description here

Advertisement

Answer

Use coalesce:

It will apply the first column/expression which is not null

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement