I would like to take a date range in python, than create a new series/column the has the date formatted as a string as YYYYMMDD
This is what I have so far:
start = '20200214' # YYYYMMDD
end = '20200216' # YYYYMMDD
dates = pd.DataFrame(pd.to_datetime(pd.date_range(start,end).date),columns = ['dates'])
dates['Year'] = dates['dates'].dt.year
dates['Month'] = dates['dates'].dt.month
dates['Day'] = dates['dates'].dt.day
I tried to add each element as a string, dates.Year.astype(str) + dates.Month.astype(str)+...
, but I need leading zeros.
So take the first date, 2020-02-14
and change it to 20200214
. Then rinse and repeat for all others.