NVIDIA / NVIDIA/cudf

[BUG]: Bug in cudf-polars to_string for datetime column with timezone

Open
#23,935 0 comments 0 reactions 0 assignees View on GitHub
? - Needs Triage bug
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

**Describe the bug**

cudf-polars doesn't match polars `to_string` when the datetime column has a timezone.

```python
def test_to_string(engine: pl.GPUEngine) -> None:
data = {
"a": [
datetime.datetime(2020, 1, 1, tzinfo=datetime.UTC),
datetime.datetime(2020, 1, 2, tzinfo=datetime.UTC),
]
}
df = pl.LazyFrame(data)
q = df.select(pl.col("a").dt.replace_time_zone(None).dt.convert_time_zone("Asia/Kathmandu"))
assert_gpu_result_equal(q, engine=engine)

q2 = q.select(pl.col("a").dt.to_string("%Y-%m-%dT%H:%M%z"))
assert_gpu_result_equal(q2, engine=engine)
```

with

```
AssertionError: DataFrames are different (value mismatch for column "a")
[left]: shape: (2,)
Series: 'a' [str]
[
"2020-01-01T05:45+0545"
"2020-01-02T05:45+0545"
]
[right]: shape: (2,)
Series: 'a' [str]
[
"2020-01-01T00:00+0000"
"2020-01-02T00:00+0000"
]
=========================================================================================================================================================== short test summary info ============================================================================================================================================================
FAILED python/cudf_polars/tests/expressions/test_datetime_timezone.py::test_to_string[in-memory] - AssertionError: DataFrames are different (value mismatch for column "a")
```

This is causing CI failures in the narhwals tests: https://github.com/NVIDIA/cudf/actions/runs/33631705030/job/100262514357?pr=23922#step:14:4243

Contributor guide

Open the contributing guide

Research direction

Start with python/cudf_polars/tests/expressions/test_datetime_timezone.py::test_to_string and reproduce the failure for the Asia/Kathmandu timezone. Trace the cudf-polars datetime to_string path and compare its result with Polars; done means the timezone-aware formatted values match and the test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.