New to Dataiku DSS? Try out our NEW Quick Start Programs today and get onboarded on the product in just one hour! Let's go

Change Precision of Double Number

Solved!
dwitkin
Level 2
Change Precision of Double Number
Hello. I have numbers in a dataset that look like this: 1.6199999999999974

I want to reduce the precision to 3 decimal places. I saw there is a format function for strings, but didn't see anything similar for numbers. What is the best way to reduce the precision to 3 decimal places? Do I need to use a script for that? If so, can you help me with what it might look like?

Thanks for your help.
1 Solution
Clément_Stenac
Dataiker
Dataiker

Hi,



Use the "Formula" processor in data preparation, with a formula like:




format("%.3f", my_column_name)


DSS formula use the Java variant of format strings: 

https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#summary



For more information about formulas, see: 

https://www.dataiku.com/learn/guide/code/misc/formula-master.html 

http://doc.dataiku.com/dss/latest/advanced/formula.html

View solution in original post

2 Replies
Clément_Stenac
Dataiker
Dataiker

Hi,



Use the "Formula" processor in data preparation, with a formula like:




format("%.3f", my_column_name)


DSS formula use the Java variant of format strings: 

https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#summary



For more information about formulas, see: 

https://www.dataiku.com/learn/guide/code/misc/formula-master.html 

http://doc.dataiku.com/dss/latest/advanced/formula.html

View solution in original post

fornanthu
Level 1
It is helpful. Thanks Clement.
0 Kudos
Labels (4)
A banner prompting to get Dataiku DSS