Skip to content
Working with Dates and Times in Python
  • AI Chat
  • Code
  • Report
  • Spinner

    Working with Dates and Times in Python

    Run the hidden code cell below to import the data used in this course.

    # Importing the course packages
    import pandas as pd
    import matplotlib.pyplot as plt
    from datetime import date, datetime, timezone, timedelta
    from dateutil import tz
    import pickle
    
    # Import the course datasets
    rides = pd.read_csv('datasets/capital-onebike.csv')
    with open('datasets/florida_hurricane_dates.pkl', 'rb') as f:
        florida_hurricane_dates = pickle.load(f)
    florida_hurricane_dates = sorted(florida_hurricane_dates)
    print(florida_hurricane_dates)

    Take Notes

    Add notes about the concepts you've learned and code cells with code you want to keep.

    Add your notes here

    # Add your code snippets here

    Explore Datasets

    Use the DataFrames imported in the first cell to explore the data and practice your skills!

    • Count how many hurricanes made landfall each year in Florida using florida_hurricane_dates.
    • Reload the dataset datasets/capital-onebike.csv so that it correctly parses date and time columns.
    • Calculate the average trip duration of bike rentals on weekends in rides. Compare it with the average trip duration of bike rentals on weekdays.