-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
P-lowPriority: lowPriority: lowblockedCannot be worked on due to external dependencies, or significant new internal features needed firstCannot be worked on due to external dependencies, or significant new internal features needed firstbugSomething isn't workingSomething isn't workingpythonRelated to Python PolarsRelated to Python Polars
Description
Checks
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of Polars.
Reproducible example
from datetime import datetime
from zoneinfo import ZoneInfo
import polars as pl
df = pl.DataFrame({"start": datetime(2021, 1, 1, tzinfo=ZoneInfo("Europe/Berlin"))})
# Correct date (2021-01-01)
print(df.select(pl.col("start").dt.date()).item())
# Incorrect date (2020-12-31)
print(df.select(pl.col("start").cast(pl.Date)).item())
Log output
2021-01-01
2020-12-31
Issue description
When casting a time-zone aware datetime column, the result differs from calling polars.Expr.dt.date()
.
Expected behavior
I would have expected that the time zone would be respected when casting—i.e., both operations return the same value.
Installed versions
--------Version info---------
Polars: 1.27.1
Index type: UInt32
Platform: macOS-15.4-arm64-arm-64bit
Python: 3.12.10 | packaged by conda-forge | (main, Apr 10 2025, 22:19:24) [Clang 18.1.8 ]
LTS CPU: False
----Optional dependencies----
Azure CLI <not installed>
adbc_driver_manager <not installed>
altair <not installed>
azure.identity <not installed>
boto3 1.37.1
cloudpickle 3.1.1
connectorx <not installed>
deltalake <not installed>
fastexcel 0.13.0
fsspec 2025.3.2
gevent <not installed>
google.auth 2.39.0
great_tables <not installed>
matplotlib 3.10.1
numpy 1.26.4
openpyxl <not installed>
pandas 2.2.3
polars_cloud <not installed>
pyarrow 19.0.1
pydantic 2.11.3
pyiceberg 0.9.0
sqlalchemy 2.0.40
torch <not installed>
xlsx2csv <not installed>
xlsxwriter <not installed>```
</details>
lmocsi, borchero, delsner and florian-klein
Metadata
Metadata
Assignees
Labels
P-lowPriority: lowPriority: lowblockedCannot be worked on due to external dependencies, or significant new internal features needed firstCannot be worked on due to external dependencies, or significant new internal features needed firstbugSomething isn't workingSomething isn't workingpythonRelated to Python PolarsRelated to Python Polars