Screen Link:
https://app.dataquest.io/m/353/working-with-dates-and-times-in-python/5/using-strptime-to-parse-strings-as-dates
My Code:
date_format = '%m/%d/%y %H:%M'
for row in potus[0:2]:
appt_start_date = row[2]
print(row)
appt_start_date = dt.datetime.strptime(appt_start_date,date_format)
print(appt_start_date)
row[2] = appt_start_date
print(row)
print("---------------------")
What I expected to happen:
['Joshua T. Blanton', '2014-12-18T00:00:00', '1/6/15 9:30', '1/6/15 23:59', '', 'potus', 'west wing', 'JointService Military Honor Guard']
2015-01-06 09:30:00
['Joshua T. Blanton', '2014-12-18T00:00:00', '2015-01-06 09:30:00', '1/6/15 23:59', '', 'potus', 'west wing', 'JointService Military Honor Guard']
---------------------
['Jack T. Gutting', '2014-12-18T00:00:00', '1/6/15 9:30', '1/6/15 23:59', '', 'potus', 'west wing', 'JointService Military Honor Guard']
2015-01-06 09:30:00
['Jack T. Gutting', '2014-12-18T00:00:00', '2015-01-06 09:30:00', '1/6/15 23:59', '', 'potus', 'west wing', 'JointService Military Honor Guard']
---------------------
What actually happened:
['Joshua T. Blanton', '2014-12-18T00:00:00', '1/6/15 9:30', '1/6/15 23:59', '', 'potus', 'west wing', 'JointService Military Honor Guard']
2015-01-06 09:30:00
['Joshua T. Blanton', '2014-12-18T00:00:00', datetime.datetime(2015, 1, 6, 9, 30), '1/6/15 23:59', '', 'potus', 'west wing', 'JointService Military Honor Guard']
---------------------
['Jack T. Gutting', '2014-12-18T00:00:00', '1/6/15 9:30', '1/6/15 23:59', '', 'potus', 'west wing', 'JointService Military Honor Guard']
2015-01-06 09:30:00
['Jack T. Gutting', '2014-12-18T00:00:00', datetime.datetime(2015, 1, 6, 9, 30), '1/6/15 23:59', '', 'potus', 'west wing', 'JointService Military Honor Guard']
---------------------
It appears to storing the command rather than the value???