Skip to content

TimezoneTransformer

TimezoneTransformer

Converts the DataFrame index from UTC to a target timezone.

Basic Usage

from epftoolbox2.data.transformers import TimezoneTransformer
transformer = TimezoneTransformer(target_tz="Europe/Warsaw")
df = transformer.transform(df)

Parameters

ParameterTypeRequiredDescription
target_tzstrYesTarget timezone name

Pipeline Order

It is recommended to add ResampleTransformer after TimezoneTransformer to fill gaps created by daylight saving time transitions:

pipeline = (
DataPipeline()
.add_source(EntsoeSource(...)) # Output: UTC
.add_transformer(LagTransformer(...)) # Lags in UTC
.add_transformer(TimezoneTransformer(target_tz="Europe/Warsaw")) # Creates DST gaps
.add_transformer(ResampleTransformer(freq="1h")) # Fills DST gaps
)

Timezone List

For a complete list of valid timezone names, see: List of tz database time zones

Common Timezones

TimezoneDescription
"Europe/Warsaw"Poland (CET/CEST)
"Europe/Berlin"Germany (CET/CEST)
"Europe/Paris"France (CET/CEST)
"Europe/London"UK (GMT/BST)
"America/New_York"US Eastern
"UTC"Coordinated Universal Time

Behavior

  • Naive index: Localized to UTC, then converted
  • Timezone-aware index: Directly converted
# Input: 2024-01-01 00:00:00+00:00 (UTC)
# Output: 2024-01-01 01:00:00+01:00 (Warsaw = CET)