rng = pd.date_range('2016-02-07', periods=7, freq='D')
print(rng[0].day)
print(rng[0].month)
7
2
I want the output with a padded zero. i.e :
07
02
a)Is there any ready function to change the format of the .day and .month?
b)Is there any other way to get day and month with padded zero ?
I have already tried the following :
rng = pd.date_range('2016-02-07', periods=7, freq='D')
r=str(rng[0])
d = datetime.strptime(r[:10], '%Y-%m-%d') #[:10] this removes time from date
z= (date.strftime(d, "%d"))
print(z)
output:
07
Thank you.