I have a list of numbers in ipython
through pyspark
like this:
df = pd.DataFrame(index=range(N))
df['total'] = data.map(lambda x:(x.features[0]+x.features[1]+x.features[2])).collect()
Now some of the numbers in this list come out to have two digits after decimal like 10.17
but there are numbers which have less than two digits after decimal like 9.1
or some do not have any decimal like 5
or 23
. What I want is to have all the numbers two digits after decimal. If they do not have two digits then an ending 0 should be added like for above 9.1
should become 9.10
and 5
should become 5.00
. How can I do that?
NOTE: I have seen posts that do that reformatting but my reformatting is in respect to the pyspark
and the map()
function specifically. How do I do the reformatting there?