# Integer to Double with Math Formula (Multi Column)

Hi,

there are already several posts concerning Integer to Double, but from my point of view it is still not solved. How do I turn multiple integer columns automatically in to double columns?

There is a node double to int, but the other direction is still missing (int to double).

The Math formula (multi column) does the job [Integer to Double Using Math], but strangely only for manual column selection. Why is the type selection missing? I have many int columns distributed amoung double columns and would like to select all int columnsâ€¦

.

Using other options and suggestions, like column rename or string to number and number to string are also not automatical, dont actually change the value type or are not intuitive (to go via string) from my point of view. (for posts see here: [Integer to Double - Maybe a small bug in KNIME?] or here [Integer2Double node])

My suggesttion: make Type Selection available in Math Formula (Multi Column)
â€¦or did I miss anything and you have another smart way of doing the job?

Cheers!

Martin

Hi there @stoeter,

As you noticed Math formula (Multi Column) node does the job and I would go with it avoiding other methods. Will check about type selection and get back to you.

Br,
Ivan

1 Like

Hi @stoeter,

From my point of view, adding type selection is senseless be cause the Math Formula (Multi Column) node only works with numeric columns. You can include all the columns and use the method in the first link you have shared to convert int columns to double and of course the double columns do not change.

Am I missing something?

1 Like

Hi,
well, yes and noâ€¦
yes, good point to just convert all columns, and it does the job!
no, math node allows and used different column type such as interger, double, long, boolean, and maybe others. No reason why type selection should not be possible!
well, converting the few int columns took 30 sec, converting all numeric columns took 13 min!! Table is middle range I would say (160000 rows times 380 columns)
Martin

1 Like

How about splitting the columns by type, converting the integers and then appending the columns?

Here is an example:
int_to_double.knwf (290.2 KB)

Well, yes another of many ways to do it. And it gives the functionality (type selection) that is wanted.

However, it needs two more columns and destroys the column order (now first all doubles, then all integer), which I dont like.

Hi there @stoeter!

Was wondering why are you transforming Integer columns to Double at all?

Br,
Ivan

Dear @ipazin,

Sometimes itâ€™s needed to do so.

For example, I have experienced a situation where I needed to loop over a table which had some integer values. These integers were transformed into variables and used in a formula and the output was a double. Since the column type was changing in the first iteration of the recursive loop, the expression could not read the variable in the next iterations (variable names contain the first letter of their type). So I had to convert the type from integer to double before the loop to overcome the issue.

Hi Ivan,
I use a group by node in a loop and some of the columns for iteration are integer. Then this gives an error if the column type is changing for the variable/node within the loop.
Martin

1 Like

That is a good point, but actually a feature request for the recursive loop node.

Because the normal loop end does have the options for this with the accept variable column types which than do the merge for you.

Also the Concatenate does support the merging.

The reason we do not have a Integer to Double node is, that all nodes accepting doubles are also accepting integer. This is why Ivan and me were curious about your use-cases.

Best wishes, Iris

2 Likes

Hi Iris,

all nodes accepting doubles are also accepting integer

â€¦that is actually a very interesting point!
When I set up my loop in the GroupBy node and use my first column for iteration, which is often integer, then the aggregation column (mean and standard variation in my case, see screen shot) are just missing when the next iteration is a double column - without any error message. If I select any double column in the configuration, then the first iteration, which is integer, still works. That means indeed, double in configuration accepts integer values, but the other way around does not work.
For me there is no problem to choose any double column in the configuration for setting up the loop, because the columns aggregated are anyway under variable controlâ€¦ problem solved and another lesson learnt in KNIME!
Thanks a lot!
Best,
Martin

ps: just to clarify, in my case I want to aggregate only selected columns that will be used downstream. The selection of the column names for aggregation is done further upstream.

1 Like

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