Python Script node is not changing the values in the column

I have the dataset, where I want to replace values in one of the columns from numeric to character values. For example I want this dataframe:

image

to become this:

image

My flow is as follows:

In my Python script node, I have the following code:

The node runs with a green status, however, when I open the table, the values are not changed, they are still numeric.

image

What am I doing wrong?

Is there a node that I can use as an alternative to this?

When I run the script it works. I’m not sure what’s happening on your end:
image

What happens if you run the script line by line and examine the output? For example, this is what I see when I run the first 2 lines:

If you’re looking for alternatives, there are a few options I can think of. If you only have a handful of replacements to make, I’d use either a series of String Replacer nodes (one for each string), or some if…then expressions in the Column Expressions node.

If you have a lot of replacements to make, I would use a String Replacer (Dictionary) node.

2 Likes

Hello @fbagirov,

sure you can use Python for this but seems like a proper job for Cell Replacer node :wink:

Br,
Ivan

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.