fix: pydantic datetime dataframe timezone conversion (#927)
Some checks failed
Close stale pull requests/issues / Find Stale issues and PRs (push) Has been cancelled
Bump Version / Bump Version Workflow (push) Has been cancelled
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
Bobby Noelte
2026-03-08 21:04:22 +01:00
committed by GitHub
parent 997e7646e9
commit 1832364d60
4 changed files with 9 additions and 5 deletions

View File

@@ -1136,9 +1136,13 @@ class PydanticDateTimeDataFrame(PydanticBaseModel):
data_tz = cls._detect_data_tz(df)
if tz is not None:
if data_tz and data_tz != tz:
raise ValueError(f"Timezone mismatch: tz='{tz}' but data uses '{data_tz}'")
resolved_tz = tz
if data_tz and data_tz != tz:
warning_msg = (
f"Forcing Pydantic dataframe timezone to '{resolved_tz}' - "
f"data timezone was '{data_tz}'."
)
logger.warning(warning_msg)
else:
if data_tz:
resolved_tz = data_tz