From the course: Data Analysis with Python and Pandas

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Formatting dates

Formatting dates

- [Instructor] Okay, so when you were just looking at the Pandas to_datetime function, I mentioned that we could specify our own custom date formats. And to be honest, we don't tend to need to do this very often because most of the datetime formats we use are going to be commonly used throughout the world. But there are going to be times when you're reading in data from a certain source where it's a very specific type of format. And we might need to use these datetime codes to help us specify the format. So here we have quite a few formats. I'm just going to go through a few of these. So %D represents the zero-padded date. So anytime we have, for example, month, if it's a single digit month, it'll be padded with a zero. This date format's going to be based on your operating system settings. So because I'm based in the United States and we have a bit strange date format, we start with month, then go to day, then go to year as our default date setting. Some of these are going to be more…

Contents