11. The datetime Data Type

11.1 Introduction

One of the biggest reasons for using Pandas is its ability to work with time-series data. We observed some of this capability earlier, when we concatenated data in Chapter 4 and saw how the indices automatically aligned themselves. This chapter focuses on the more common tasks when working with data that involve dates and times.

Objectives

This chapter will cover:

1. Python’s built-in datetime library

2. Converting strings into a date

3. Formatting dates

4. Extracting date components

5. Performing calculations with dates

6. Working with dates in a DataFrame

7. Resampling

8. Working with time zones

11.2 Python’s datetime Object

Python has a built-in datetime object that is found in the datetime ...

Get Pandas for Everyone: Python Data Analysis, First Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.