Note
Pandas (48) 본문
728x90
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%
'Pandas' 카테고리의 다른 글
Pandas (50) (0) | 2022.09.16 |
---|---|
Pandas (49) (0) | 2022.09.15 |
Pandas (47) (0) | 2022.09.13 |
Pandas (46) (0) | 2022.09.12 |
Pandas (45) (0) | 2022.09.11 |
Comments