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

feat(python,rust): extend dtype/selector matching for Datetime with a "*" wildcard for timezones #9641

Merged
merged 4 commits into from
Jul 2, 2023

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Jun 30, 2023

Closes #5300.

Allows the pl.DATETIME_DTYPES group to cover all timeunit/timezone combinations.

Further enhances the cs.datetime selector so that it can handle arbitrary permutations of timeunit/timezone, eg:

  • cs.datetime() → any timeunit, any (or no) timezone
  • cs.datetime( time_zone="*" ) → any timeunit, any timezone (but must have a timezone)
  • cs.datetime( time_zone=None ) → any timeunit, no timezone
  • cs.datetime( ["ms","ns"], time_zone="UTC" ) → any col with UTC timezone and ns or ms precision
  • cs.datetime( time_zone=["UTC","Asia/Tokyo","Europe/London"] ) → any timeunit, one of the given timezones

(Note: all of the expressions above could also be negated using ~).

Finally adds the missing piece to the Datetime dtype selection puzzle that has been timezones... :)

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars labels Jun 30, 2023
Copy link
Collaborator

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool! love how ergonomics keep improving

py-polars/polars/selectors.py Show resolved Hide resolved
Copy link
Member

@ritchie46 ritchie46 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice ergonomic change. I think we must go through with this, but with a slightly different implementation. See comment.

polars/polars-core/src/datatypes/dtype.rs Outdated Show resolved Hide resolved
py-polars/polars/selectors.py Show resolved Hide resolved
@ritchie46 ritchie46 merged commit a5f2604 into pola-rs:main Jul 2, 2023
@alexander-beedie alexander-beedie deleted the datetime-timezone-wildcard branch July 2, 2023 07:29
CloseChoice pushed a commit to CloseChoice/polars that referenced this pull request Jul 9, 2023
c-peters pushed a commit to c-peters/polars that referenced this pull request Jul 14, 2023
@alexander-beedie alexander-beedie added the A-selectors Area: column selectors label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-selectors Area: column selectors enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't exclude datetime[ns] by targeting pl.DateTime
3 participants