From the course: Advanced Pandas

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Working with dates using pandas

Working with dates using pandas

From the course: Advanced Pandas

Start my 1-month free trial

Working with dates using pandas

- [Instructor] Time series data is one of the most interesting and essential types of data that we work with. But dates can be tricky to deal with. Thankfully, Pandas has some excellent methods that we can put to use. To get started, we're going to generate a series of dates. The period_range function in Pandas allows us to do just that. By specifying the starting date, followed by the frequency, and the number of periods, we return a series of dates which we'll pass into a data frame. Great. Now we've got a data frame of four dates starting January 1st, 2020. And each is separated by 30 days. One useful function when working with time series data is the diff function. Diff will calculate the difference from a prior period. And in this sense operates similar to a SQL lag function. Let's see the difference from the prior date in our data. Sure enough, our dates are 30 days apart. Now often you'll want to take a…

Contents