how can I change float to percentage with specific precision python

81 Views Asked by At

I'd like to change float values to percent with precision of 3 decimal points.

This is what I tried:

df.style.format('var3': "{:.3%}",'var1': "{:.3%}",'var4': "{:.3%}", 'var5': "{:.3%}"})
display(df)

this is what I'm getting:

input:

var1: 0.0092592592592592

output

var1 : 0.900%

This is what I would like o get as output:

var1: 0.926%

Appreciate the help..

1

There are 1 best solutions below

0
R.A On BEST ANSWER

This worked for me: df[col].map('{:.3%}'.format)