I have a list of start and end times data of bike rides. Below are the first 5 entries of the list.
onebike_datetimes[0:4]
[{'start': datetime.datetime(2017, 10, 1, 15, 23, 25, tzinfo=tzfile('US/Eastern')),
'end': datetime.datetime(2017, 10, 1, 15, 26, 26, tzinfo=tzfile('US/Eastern'))},
{'start': datetime.datetime(2017, 10, 1, 15, 42, 57, tzinfo=tzfile('US/Eastern')),
'end': datetime.datetime(2017, 10, 1, 17, 49, 59, tzinfo=tzfile('US/Eastern'))},
{'start': datetime.datetime(2017, 10, 2, 6, 37, 10, tzinfo=tzfile('US/Eastern')),
'end': datetime.datetime(2017, 10, 2, 6, 42, 53, tzinfo=tzfile('US/Eastern'))},
{'start': datetime.datetime(2017, 10, 2, 8, 56, 45, tzinfo=tzfile('US/Eastern')),
'end': datetime.datetime(2017, 10, 2, 9, 18, 3, tzinfo=tzfile('US/Eastern'))}]
I know for sure my list has some dates adjusted for day light savings. I am applying the following code to check if there are any dates that are ambiguous for day light savings start and end points. However, when did so, I am getting value error. Any suggestions, where could be the problem?
from dateutil import tz
for trip in onebike_datetimes:
# Rides with ambiguous start
if tz.datetime_ambiguous(trip['start']):
print("Ambiguous start at " + str(trip['start']))
# Rides with ambiguous end
if tz.datetime_ambiguous(trip['end']):
print("Ambiguous end at " + str(trip['end']))
ValueError: Datetime is naive and no time zone provided.