If you want to get a dataframe from pandas, the date_range
function does all the work for you (doc). The pd.datetime.now()
method gives you the current date (doc)
Here one example:
def get_df_days_to_now(year, month, day = 1):
date_start = "%4d/%d/%d" % (year, month, day)
date_end = pd.datetime.now().strftime("%d/%m/%Y")
return pd.date_range(start=date_start, end=date_end, freq="D")
print(get_df_days_to_now(2019, 5))
# DatetimeIndex(['2019-05-01', '2019-05-02', '2019-05-03', '2019-05-04',
# '2019-05-05', '2019-05-06', '2019-05-07', '2019-05-08',
# '2019-05-09', '2019-05-10', '2019-05-11', '2019-05-12',
# '2019-05-13', '2019-05-14', '2019-05-15', '2019-05-16',
# '2019-05-17', '2019-05-18', '2019-05-19', '2019-05-20',
# '2019-05-21', '2019-05-22'],
# dtype = 'datetime64[ns]', freq = 'D')