# import pandasFrom StackOverflow
Strings:
>>> n = '4'
>>> print n.zfill(3)
>>> '004'And for numbers:
>>> n = 4
>>> print '%03d' % n
>>> 004
>>> print format(4, '03') # python >= 2.6
>>> 004
>>> print '{0:03d}'.format(4) # python >= 2.6
>>> 004
>>> print('{0:03d}'.format(4)) # python 3
>>> 004Turn them off for a specific function
import warnings
def fxn():
warnings.warn("deprecated", DeprecationWarning)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
fxn()
Turn off everything (not condoned):
import warnings
warnings.filterwarnings("ignore")