Time Zones

Discover the methods for handling time zones within time series objects.

Introduction

Time zones play a significant role in time series data analysis, because businesses often span multiple regions with different time zones. Understanding time zones is important for the correct interpretation and alignment of data. For instance, comparing stock market data from various areas without considering time zones may result in inaccurate insights.

Time zone conversions

The pandas library's objects are timezone-unaware by default, meaning they aren’t assigned to any specific time zone. To set a time zone for time series objects, we can utilize either of the following two commonly-used ways:

  • Use the tz keyword argument when creating time series objects with classes (Timestamp, DatetimeIndex) or methods (e.g., date_range()).

  • Use the tz_localize() method.

Note: If a time series object already has a time zone assigned, using tz_localize() will raise a TypeError.

There are also three common ways ...

Get hands-on with 1400+ tech skills courses.