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-mode schema does not reflect timezone conversion #7008

Closed
2 tasks done
erinov1 opened this issue Feb 18, 2023 · 1 comment · Fixed by #7022
Closed
2 tasks done

Lazy-mode schema does not reflect timezone conversion #7008

erinov1 opened this issue Feb 18, 2023 · 1 comment · Fixed by #7022
Labels
bug Something isn't working python Related to Python Polars

Comments

@erinov1
Copy link

erinov1 commented Feb 18, 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

In eager mode, the schema is aware of timezone conversions:

df = pl.DataFrame({"dt": [datetime.datetime(2021, 1, 1)]})
df.with_columns(
    pl.col("dt").dt.replace_time_zone("UTC").dt.convert_time_zone("America/New_York")
).schema

{'dt': Datetime(tu='us', tz='America/New_York')}

But in lazy mode the schema does not reflect the timezone conversion:

ldf = df.lazy()
ldf.with_columns(
    pl.col("dt").dt.replace_time_zone("UTC").dt.convert_time_zone("America/New_York")
).schema

{'dt': Datetime(tu='us', tz='UTC')}

Reproducible example

import datetime
import polars as pl

ldf = pl.DataFrame({"dt": [datetime.datetime(2021, 1, 1)]}).lazy()
ldf.with_columns(
    pl.col("dt").dt.replace_time_zone("UTC").dt.convert_time_zone("America/New_York")
).schema

Expected behavior

The schema in lazy mode should also be

{'dt': Datetime(tu='us', tz='America/New_York')}

Installed versions

---Version info---
Polars: 0.16.6
Index type: UInt32
Platform: macOS-13.2-arm64-arm-64bit
Python: 3.10.9 (main, Feb 12 2023, 18:51:31) [Clang 14.0.0 (clang-1400.0.29.202)]
---Optional dependencies---
pyarrow: 11.0.0
pandas: 1.5.3
numpy: 1.24.2
fsspec: 2023.1.0
connectorx: <not installed>
xlsx2csv: <not installed>
deltalake: <not installed>
matplotlib: 3.7.0
@erinov1 erinov1 added bug Something isn't working python Related to Python Polars labels Feb 18, 2023
@MarcoGorelli
Copy link
Collaborator

thanks for reporting 🙏 working on a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Related to Python Polars
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants