Pandas
Pandas (48)
Jun's N
2022. 9. 14. 19:23
How to format all the values in a dataframe as percentages?
# Input
df = pd.DataFrame(np.random.random(4), columns=['random'])
# Solution
out = df.style.format({
'random': '{0:.2%}'.format,
})
out
# output
random
0 21.66%
1 44.90%
2 85.69%
3 92.12%
728x90