How to sum the numbers in a string column
I have a string column ("CylSize") with these values (7.5, 7.5, 5.125, 3.375).
We need to create a new column with the sum of all the values (7.5+7.5+5.125+3.375) = 23.5.
Please advise what is the best recipe to get it done.
Operating system used: Windows
Best Answer
-
Miguel Angel Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 118 Dataiker
Hi,
The sum of elements in the same cell can be easily achieved by using a Prepare recipe. Within this recipe, there are various ways in which the desired results can be obtained.
The most straigtforward path would be to take advantage of visual processors. For example, using the following: 'extract numbers', 'formula', and 'remove columns'.
Another option to do the operations in one go could be using a 'custom python function':
Answers
-
Miguel,
Thanks for your help!
I tried the 'custom python function,' and it worked great.