sunpeek.common.time_zone.validate_timezone#
- sunpeek.common.time_zone.validate_timezone(idx, timezone, plant=None)#
Validates timezone information, trying to match DataFrame timezone and timezone string.
- Parameters:
idx (
pd.DatetimeIndex
)timezone (
str
orpytz.timezone
) – If string, pytz must be able to parse that string into a timezone. Examples of valid inputs: ‘Europe/Berlin’ or pytz.timezone(‘Europe/Berlin’) or pytz.timezone(‘UTC’) or pytz.FixedOffset(60)plant (
sunpeek.components.Plant
)
- Returns:
idx – timezone-aware index
- Return type:
- Raises:
Notes
Here is how all combinations are handled: 1. No timezone in df, but timezone string given: ok 2. Timezone in df, and no timezone string given: ok 3. No timezone in df, and no timezone string given: error (timezone info is missing) 4. Timezone both in df and as timezone string: error (because it’s hard to check compatibility between a
dynamically-offset string-based timezone like ‘Europe/Vienna’ with a FixedOffset timezone info that is the result of parsing timezone-aware timestamps).
See also