Rounding 2 digit after decimal in pyspark dataframe
Answers
Answered by
0
Answer:
I am following this solution from one of the stack overflow post, my only requirement here is how can I limit the values that I want to sum to 2 digit after the decimal before applying the df.agg(sum()) function?
For examples: I have values like below and the sum function sums it,
2.346
1.549
However I want the values to be rounded to 2 digit after the decimal like
2.35
1.55
before summing it. How can I do it? I was not able to find any sub function like sum().round of function sum.
Note: I am using Spark 1.5.1 version.
Similar questions