Replace NA across multiple columns

Hello,

I have multiple columns with “NA” and want to replace all of them with “none”. How would I do this? I tried the string manipulation (multi column) node but it did not work, it changed every cell in selected columns to none. I’ve tried the string replacer too but I have around 12 columns and I would need to do this for each column individually.

Thank you

Hi @Subha_D try to use the “autotype cast” node by setting the “missing field value pattern” to NA then, after that, use the missing values node ​​to replace with the word none

3 Likes

Hello @Subha_D,

String Manipulation (Multi Column) should work with replace() function. How did you configure it?

Br,
Ivan

1 Like

Thanks @natanaeldgsantos it works!

1 Like

Hi @ipazin I selected the columns i wanted to edit then used : replace(“NA”,“NA” ,“None” ). Not sure if this right though…

Hello @Subha_D,

first argument is string/column(s) in which you would like to make replacement. In order to do it for multiple columns you should use currentColumn placeholder and include wanted columns. Something like this:

replace($$CURRENTCOLUMN$$,"Na","None")

Br,
Ivan

2 Likes

Thank you! It works now

1 Like

Glad to hear that!
Ivan

I once saw a solution from @ipazin in the forum where he unpivoted the data, did the replace and pivoted again. That should also work

2 Likes

Hello,

here is workflow example on approach @Daniel_Weikert is talking about.

That seems to me way to go when in need to apply same expression/operation on multiple columns and can’t use String Manipulation/Math Formula (Multi Column) nodes.

Br,
Ivan

4 Likes