Search⌘ K
AI Features

Business Hours

Explore how to use pandas' BusinessHour and CustomBusinessHour classes to manage time series data within specific business hours. Learn to adjust start and end times, handle arithmetic operations on timestamps, and customize business schedules with holidays and varied weekends. This lesson equips you with skills to accurately analyze data while respecting operational hours.

Introduction

Let’s go one step beyond business days and look at the more granular component of business hours. As an extension to the concept of business days, business hours refer to the operating hours of a business day.

This concept of business hours is important when performing operations that need to respect a business’ specific hours of operation. For instance, if we analyze hourly sales data for a business and want to calculate the total sales for each business day, we would want to exclude data outside the business hours.

By default, the business hours in pandas are defined as Monday–Friday, 9 AM to 5 PM, excluding holidays.

The BusinessHour offset

To discuss business hour representations, we’ll need to work with DateOffset objects in pandas. In particular, the BusinessHour() ...