Feedback and Help Request: datetime strptime issues

Hi all, I’m having some truouble using datetime features on my project inspired by one of the lessons in DataQuest.

J05_2016_WH_Visitor_Data_2.ipynb (13.8 KB)

My major concerns are the following:

The earliest time appointments start at 0:00 instead of what I would imagine morning regular hours, even after an attempt to change start times to 12:00.

Finally, I’m unable to successfully use the strptime datetime feature here and get a format error.

Perhaps you can find other areas for improvement, clarification.

Thank you very much for your help.


1 Like

Hi @ftclaudia.a

I have downloaded the dataset of 2016 White House visitor’s record from the link given in the notebook, and after exploring, I can’t find any appointments which start with 00:00 in the dataset.

Or maybe the dataset you are using is different. If you can share your dataset, then I will look at it.

One suggestion completes the Pandas and NumPy Fundamentals course, so it will become easier for you to explore the data.

Hi Prem,

Thank you for taking the time to review this with me, as I would really like to get this solved. Please see the dataset linked below:

I tried manipulating it and nothing seems to work for me.

Thanks again,

For reference: I’ve also included the dataset included in the mission and the notebook attempting the same issues. On the last cell I get an error:

ValueError: time data ‘2015-01-06 09:30:00’ does not match format ‘%m/%d/%y %H:%M’

J05_2016_WH_Visitor_Data.ipynb (13.6 KB)

I hope this helps.

Click here to view the jupyter notebook file in a new tab

Claudia, you can also upload the dataset here (if not big in size). And the ValueError is because you haven’t mentioned the place for seconds in the match format.

Hi Prem, even when I add :%S to the code I get the same error. Notice the way the date is ordered in the error: ‘2015-01-06 09:30:00’ is different than the output of dates in the rest of the code ‘1/6/15…’ I tried cleaning that in cell 5 with no success. Not sure what I can do to potentially address all dates in the incorrect format here.

I hope this helps.

I want to figure this out, even though I’ve moved on in my missions. I’d love to get this right.

Hey Claudia,

I just requested access to the dataset in your drive. Can you give me the access show that I can look at it?

@ftclaudia.a tagging you show that you get a notification.

If you see DateTime and the format, both are entirely different. A year comes first in data, and according to your format, there will be a month.

Use %Y-%m-%d %H:%M:%S format to parse the DateTime and see the difference between both the formats. Also, the string of DateTime matches the format.

And the error in the first notebook for the 2016 dataset, you added 12:00 for an appointment start date if there is no time but not done anything for appointment end date it also contains date without time that’s why parsing DateTime using %m/%d/%y %H:%M format gives an error.

I hope this helps.

Hi Prem,

Thanks for getting back to me.

That’s part of the issue. I don’t see format %Y-%m-%d %H:%M:%S at all other than for the appt made date which is on column 2 and not 3 appt start date [2] that I’m working with. When I open up the file, I see the the format %m/%d/%y %H:%M for the 3rd and 4th columns that I’m trying to work with at the end.

I used the dt format successfully in the 7th cell, up until the 11th, using %m/%d/%y %H:%M then suddenly I get a value error message. I don’t have a lot of experience using datetime and strptime but that is odd to me and I’m not seeing how to fix it.

I tried your recommendation, and nothing happened. No error, but no output altogether.

Thanks again for helping work this out.


Sorry, Claudia (@ftclaudia.a), for the late response. The format of the 3rd and 4th column changes just after the parsing in the 7th cell. That’s why when you try to parse again in the 11th cell, it gives an error.

You can check it after printing the 3rd and 4th column data just after the 7th cell.

Hi Prem. My apologies as well. Thank you for providing this resource, and indeed you are right. After the 7th cell the format changes. I have reviewed and made the changes needed to run this correctly. Thanks again for your help getting this solved!

All my best,

1 Like

You can find the working project on my Github.

1 Like