How to deal with infinite values?

Hi all,
I was trying to substitute infinite values of a certain column using the expression reported by @AlexanderFillbrunn in this thread.
Unfortunately it seems that in my case the expression doesn’t work because the Math Formula node gives me the following error:

Is there something I misunderstood? Do you have any suggestions?
Thanks in advance
Gio

Hi,
Can you share a table file with your data (a sample is enough)?
Kind regards,
Alexander

1 Like

Hi @AlexanderFillbrunn, thank you for your quick reply and help!
I realised that the problem was just because I was using a flow_variable in the expression instead of the column name. This is why I was having that “Unrecognized symbol Infinity” error. Correcting that, your expression works fine to remove infinity!!

I have another question though: to me its seems that your expression evaluates to “undefined” when you have an infinite value on the reference column. The problem is that the part on the left of the + become undefined in that case:

Original expression:

(1 - isInfinite($column$)) * $column$ + isInfinite($column$) * <replacement>

When value of $column$ is infinite:

(1 - 1) * Infinite + 1 * <replacement>

And:

0 * Infinite = Undefined

Is that what you expect?

Anyway, the expression is very useful as the Undefined value can then be set = to a fix value by using the Missing Value node.

3 Likes

Hi,
You are right. You could get around this by “cheating” and making use of the fact that in the background the Math Formula is still Java. So something like this could also work:

isInfinite($column$) == 1 ? <replacement> : $column$

This is the Java ternary operator, basically an inline-If.
Kind regards,
Alexander

4 Likes

Hi Alexander,
Thank you for your answer. I’m sorry to insist, but perhaps this thread will be useful also to other people in the future.
In the attached example workflow I tried to apply the Math Formula node using this expression as you suggested:

isInfinite($result$) == 1 ? 0 : $result$

But it gives me the following error:

Invalid settings: Unable to parse m_expression Syntax error

Did I misunderstand anything? :thinking:
I’ve also tried to pass the expression to the node as a flow variable but it gives me the same error.

Thanks for any clarification

infinite_check_expression.knwf (9.1 KB)

1 Like

I think @AlexanderFillbrunn was referring to the column expression node which supports the syntax
br

isInfinite(column("result")) == 1 ? 0 : column("result")
3 Likes

Hi,
It was a mistake on my side. It does work with the String Manipulation node, but not with Math Formula. As @Daniel_Weikert mentioned, the Column Expression is the way to go.
Kind regards,
Alexander

2 Likes

That works perfectly thank you @Daniel_Weikert and @AlexanderFillbrunn!!

1 Like

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