Skip to main content
HomePythonWorking with Dates and Times in Python

Working with Dates and Times in Python

4.4+
35 reviews
Intermediate

Learn how to work with dates and times in Python.

Start Course for Free
4 hours14 videos48 exercises61,694 learnersTrophyStatement of Accomplishment

Create Your Free Account

GoogleLinkedInFacebook

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.
Group

Training 2 or more people?

Try DataCamp For Business

Loved by learners at thousands of companies


Course Description

You'll probably never have a time machine, but how about a machine for analyzing time? As soon as time enters any analysis, things can get weird. It's easy to get tripped up on day and month boundaries, time zones, daylight saving time, and all sorts of other things that can confuse the unprepared. If you're going to do any kind of analysis involving time, you’ll want to use Python to sort it out. Working with data sets on hurricanes and bike trips, we’ll cover counting events, figuring out how much time has elapsed between events and plotting data over time. You'll work in both standard Python and in Pandas, and we'll touch on the dateutil library, the only timezone library endorsed by the official Python documentation. After this course, you'll confidently handle date and time data in any format like a champion.
For Business

GroupTraining 2 or more people?

Get your team access to the full DataCamp library, with centralized reporting, assignments, projects and more
Try DataCamp for BusinessFor a bespoke solution book a demo.

In the following Tracks

Certification Available

Associate Data Scientist in Python

Go To Track

Associate Python Developer

Go To Track

Python Programming Toolbox

Go To Track
  1. 1

    Dates and Calendars

    Free

    Hurricanes (also known as cyclones or typhoons) hit the U.S. state of Florida several times per year. To start off this course, you'll learn how to work with date objects in Python, starting with the dates of every hurricane to hit Florida since 1950. You'll learn how Python handles dates, common date operations, and the right way to format dates to avoid confusion.

    Play Chapter Now
    Dates in Python
    50 xp
    Which day of the week?
    100 xp
    How many hurricanes come early?
    100 xp
    Math with dates
    50 xp
    Subtracting dates
    100 xp
    Counting events per calendar month
    100 xp
    Putting a list of dates in order
    100 xp
    Turning dates into strings
    50 xp
    Printing dates in a friendly format
    100 xp
    Representing dates in different ways
    100 xp
  2. 2

    Combining Dates and Times

    Bike sharing programs have swept through cities around the world -- and luckily for us, every trip gets recorded! Working with all of the comings and goings of one bike in Washington, D.C., you'll practice working with dates and times together. You'll parse dates and times from text, analyze peak trip times, calculate ride durations, and more.

    Play Chapter Now
  3. 3

    Time Zones and Daylight Saving

    In this chapter, you'll learn to confidently tackle the time-related topic that causes people the most trouble: time zones and daylight saving. Continuing with our bike data, you'll learn how to compare clocks around the world, how to gracefully handle "spring forward" and "fall back," and how to get up-to-date timezone data from the dateutil library.

    Play Chapter Now
  4. 4

    Easy and Powerful: Dates and Times in Pandas

    To conclude this course, you'll apply everything you've learned about working with dates and times in standard Python to working with dates and times in Pandas. With additional information about each bike ride, such as what station it started and stopped at and whether or not the rider had a yearly membership, you'll be able to dig much more deeply into the bike trip data. In this chapter, you'll cover powerful Pandas operations, such as grouping and plotting results by time.

    Play Chapter Now
For Business

GroupTraining 2 or more people?

Get your team access to the full DataCamp library, with centralized reporting, assignments, projects and more

In the following Tracks

Certification Available

Associate Data Scientist in Python

Go To Track

Associate Python Developer

Go To Track

Python Programming Toolbox

Go To Track

datasets

Florida HurricanesW20529 Bike Data (Capital Bikeshare)

collaborators

Collaborator's avatar
Chester Ismay
Collaborator's avatar
Sumedh Panchadhar
DataCamp Content Creator

Course Instructor

DataCamp offers interactive R, Python, Spreadsheets, SQL and shell courses. All on topics in data science, statistics, and machine learning. Learn from a team of expert teachers in the comfort of your browser with video lessons and fun coding challenges and projects.
See More

Don’t just take our word for it

*4.4
from 35 reviews
66%
20%
9%
3%
3%
Sort by
  • Li D.
    2 months

    Great

  • Reithabetse K.
    3 months

    It was easy to understand, with great demonstrations.

  • Julio M.
    4 months

    Un corto y muy eficiente curso.

  • Tharun N.
    4 months

    good stuff

  • Urich K.
    5 months

    -

"Great"

Li D.

"It was easy to understand, with great demonstrations."

Reithabetse K.

"Un corto y muy eficiente curso."

Julio M.

Join over 14 million learners and start Working with Dates and Times in Python today!

Create Your Free Account

GoogleLinkedInFacebook

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.