how to change a percent number string to double ?

HI  everyone

now i am using groupby node .i choose a column ( datatype is like 89.26% ), but in th dialog ,i can't find  mean in the aggregation. i think  i shoud change 89.26% to  0.8926 . Perhaps 89.26% is string type .how  to change??

Hi mourn,

If in the aggregation options inside the GroupBy node you see "Concatenate", "Count", "First", "Last" etc. for your percentage column it means that column is of type string. You can double check by inspecting it. Until you convert it to numeric it will not be possible to calculate any mean or other numerical statistics for it.

You can either fix the way your data is loaded in or convert your percentage string to double inside KNIME. In the last case you can:

- Use a String Manipulation node to remove the final "%" sign, then

- Use a String to Number node to convert the numeric string to double, then

- Use a Math Formula node to divide the number by 100.

At this point you have converted your percentages from string to double and the GroupBy node will allow you to calculate their mean.

Cheers,
Marco.

2 Likes