My list of timestamps is given below:
time_list =
[Timestamp('2019-01-24 00:00:00'),
Timestamp('2019-01-27 00:00:00'),
Timestamp('2019-01-29 00:00:00'),
Timestamp('2019-02-08 00:00:00'),
Timestamp('2019-02-09 00:00:00'),
Timestamp('2019-02-10 00:00:00')]
I would like to take only the date part and convert it to a string. My code is
aux1 = []
for i in time_list:
aux1.append(str(i))
date_list = aux1
Present output is:
date_list =
['2019-01-24 00:00:00',
'2019-01-27 00:00:00',
'2019-01-29 00:00:00',
'2019-02-08 00:00:00',
'2019-02-09 00:00:00',
'2019-02-10 00:00:00']
However the output I want is:
date_list =
['2019-01-24',
'2019-01-27',
'2019-01-29',
'2019-02-08',
'2019-02-09',
'2019-02-10']
In my code I have used for
loop approach but it is not producing the desired answer. Is there a better approach to get my desired date_list
?