Skip to content

Python code snippet – How to add zeros in front of numbers in pandas?

number = 15 # number of zeroes to add
df['ID'] = df['ID'].str.zfill(number)
See also  How to print a message in Python?
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.