Screen Link:
https://app.dataquest.io/m/353/working-with-dates-and-times-in-python/10/summarizing-appointment-lengths
My Code:
for row in potus:
end_date = row[3]
end_date = dt.datetime.strptime(end_date, "%m/%d/%y %H:%M")
row[3] = end_date
## My Code
appt_lengths = {}
for visit in potus:
start = visit[2]
end = visit[3]
length = end - start
if length not in appt_lengths:
appt_lengths[length] = 1
else:
appt_lengths[length] += 1
min_length = min(appt_lengths)
max_length = max(appt_lengths)
What I expected to happen:
To my knowledge my code should run just fine. The problem lies in the first for-loop that was already provided.
What actually happened:
The for-loop that was provided does not run as expected.
TypeErrorTraceback (most recent call last)
<ipython-input-1-1f6acccb961f> in <module>()
1 for row in potus:
2 end_date = row[3]
----> 3 end_date = dt.datetime.strptime(end_date, "%m/%d/%y %H:%M")
4 row[3] = end_date
5
TypeError: must be str, not datetime.datetime