I have dataframe like below
month
0 1
1 2
2 3
3 10
4 11
for example,I would like to display this dataframe in 2 digit like this
month
0 01
1 02
2 03
3 10
4 11
I tried many method but didn't work well. How can I get this result?
You can use str.zfill
:
print (df['month'].astype(str).str.zfill(2))
0 01
1 02
2 03
3 10
4 11
Name: month, dtype: object
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With