0

I have a list of dates that are datetime64 objects. I want to compare these dates to a larger list of dates that are in string format:

large_list = ['2019-12-30', '2019-12-31', '2020-01-01', '2020-01-02'] #etc...
smaller_list = [2019-12-30 00:00:00, 2019-12-31 00:00:00, 2020-01-01 00:00:00] #etc..

is there any way I can convert the smaller list into a list of strings similar to the larger list so that I can compare the respective dates?

1 Answers1

0
smaller_list = [ str(each_date) [:-9] for each_date in smaller_list] 

it will become similar to the larger_list

Another work around will be to convert strings to date and then compare them for that you may look in here.

https://opensource.com/article/18/4/python-datetime-libraries

Daud Ahmed
  • 190
  • 1
  • 10