Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lazy date_range doesn't respect time zone #8512

Closed
2 tasks done
MarcoGorelli opened this issue Apr 26, 2023 · 0 comments · Fixed by #8591
Closed
2 tasks done

lazy date_range doesn't respect time zone #8512

MarcoGorelli opened this issue Apr 26, 2023 · 0 comments · Fixed by #8591
Labels
A-temporal Area: date/time functionality bug Something isn't working python Related to Python Polars

Comments

@MarcoGorelli
Copy link
Collaborator

MarcoGorelli commented Apr 26, 2023

Polars version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of Polars.

Issue description

The following outputs

shape: (3, 4)
┌──────┬─────────────────────┬─────────────────────┬───────────────────────────────────┐
│ namefromtodate_range                        │
│ ------------                               │
│ strdatetime[μs]        ┆ datetime[μs]        ┆ list[datetime[μs]]                │
╞══════╪═════════════════════╪═════════════════════╪═══════════════════════════════════╡
│ A2020-01-01 00:00:002020-01-02 00:00:00 ┆ [2020-01-01 00:00:00, 2020-01-02… │
│ B2020-01-02 00:00:002020-01-03 00:00:00 ┆ [2020-01-02 00:00:00, 2020-01-03… │
│ C2020-01-03 00:00:002020-01-04 00:00:00 ┆ [2020-01-03 00:00:00, 2020-01-04… │
└──────┴─────────────────────┴─────────────────────┴───────────────────────────────────┘

Reproducible example

df = pl.DataFrame(
    {
        "name": ["A", "B", "C"],
        "from": [datetime(2020, 1, 1), datetime(2020, 1, 2), datetime(2020, 1, 3)],
        "to": [datetime(2020, 1, 2), datetime(2020, 1, 3), datetime(2020, 1, 4)],
    }
)
print(
    df.with_columns(
        pl.date_range(
            start=pl.col("from"),
            end=pl.col("to"),
            interval="1d",
            lazy=True,
            time_zone="Asia/Kathmandu",
        ).alias("date_range")
    )
)

Expected behavior

shape: (3, 4)
┌──────┬─────────────────────┬─────────────────────┬────────────────────────────────────┐
│ name ┆ from                ┆ to                  ┆ date_range                         │
│ ---  ┆ ---                 ┆ ---                 ┆ ---                                │
│ str  ┆ datetime[μs]        ┆ datetime[μs]        ┆ list[datetime[μs, Asia/Kathmandu]] │
╞══════╪═════════════════════╪═════════════════════╪════════════════════════════════════╡
│ A    ┆ 2020-01-01 00:00:00 ┆ 2020-01-02 00:00:00 ┆ [2020-01-01 00:00:00 +0545, 2020…  │
│ B    ┆ 2020-01-02 00:00:00 ┆ 2020-01-03 00:00:00 ┆ [2020-01-02 000:00:00 +0545, 2020…  │
│ C    ┆ 2020-01-03 00:00:00 ┆ 2020-01-04 00:00:00 ┆ [2020-01-03 00:00:00 +0545, 2020…  │
└──────┴─────────

Installed versions

---Version info---
Polars: 0.17.8
Index type: UInt32
Platform: Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
Python: 3.8.16 (default, Dec  7 2022, 01:12:06)
[GCC 11.3.0]
---Optional dependencies---
numpy: 1.24.2
pandas: 1.5.3
pyarrow: 11.0.0
connectorx: <not installed>
deltalake: <not installed>
fsspec: <not installed>
matplotlib: 3.6.2
xlsx2csv: <not installed>
xlsxwriter: <not installed>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-temporal Area: date/time functionality bug Something isn't working python Related to Python Polars
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant