diff --git a/polars/polars-core/src/series/from.rs b/polars/polars-core/src/series/from.rs index aee945273a20..6816a2c79bba 100644 --- a/polars/polars-core/src/series/from.rs +++ b/polars/polars-core/src/series/from.rs @@ -200,8 +200,9 @@ impl Series { let mut tz = tz.clone(); if tz.as_deref() == Some("") { tz = None; - } - if let Some(_tz) = &tz { + } else if tz.as_deref() == Some("+00:00") { + tz = Some("UTC".to_string()); + } else if let Some(_tz) = &tz { #[cfg(feature = "timezones")] validate_time_zone(_tz)?; } diff --git a/py-polars/tests/unit/io/files/tz_aware.parquet b/py-polars/tests/unit/io/files/tz_aware.parquet new file mode 100755 index 000000000000..8baad68da983 Binary files /dev/null and b/py-polars/tests/unit/io/files/tz_aware.parquet differ diff --git a/py-polars/tests/unit/io/test_parquet.py b/py-polars/tests/unit/io/test_parquet.py index c3bce23c1cb8..556a3efbbf39 100644 --- a/py-polars/tests/unit/io/test_parquet.py +++ b/py-polars/tests/unit/io/test_parquet.py @@ -1,6 +1,8 @@ from __future__ import annotations import io +import os +from datetime import datetime, timezone from typing import TYPE_CHECKING import numpy as np @@ -507,3 +509,13 @@ def test_parquet_string_cache() -> None: # so polars should automatically set string cache f.seek(0) assert_series_equal(pl.read_parquet(f)["a"].cast(str), df["a"].cast(str)) + + +def test_tz_aware_parquet_9586() -> None: + result = pl.read_parquet( + os.path.join("tests", "unit", "io", "files", "tz_aware.parquet") + ) + expected = pl.DataFrame( + {"UTC_DATETIME_ID": [datetime(2023, 6, 26, 14, 15, 0, tzinfo=timezone.utc)]} + ).select(pl.col("*").cast(pl.Datetime("ns", "UTC"))) + assert_frame_equal(result, expected)