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: pyarrow automated inference of format %Y%m%d%H%M%S #1326

Merged
merged 8 commits into from
Nov 10, 2024

Conversation

raisadz
Copy link
Contributor

@raisadz raisadz commented Nov 5, 2024

What type of PR is this? (check all applicable)

  • πŸ’Ύ Refactor
  • ✨ Feature
  • πŸ› Bug Fix
  • πŸ”§ Optimization
  • πŸ“ Documentation
  • βœ… Test
  • 🐳 Other

Related issues

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below.

@github-actions github-actions bot added the enhancement New feature or request label Nov 5, 2024
@raisadz raisadz marked this pull request as ready for review November 5, 2024 17:26
Copy link
Collaborator

@EdAbati EdAbati left a comment

Choose a reason for hiding this comment

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

Thank you for this! I just have a minor comment below, but it looks already great

tests/expr_and_series/str/to_datetime_test.py Outdated Show resolved Hide resolved
Copy link
Member

@FBruzzesi FBruzzesi left a comment

Choose a reason for hiding this comment

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

Thanks @raisadz !

I didn't know that polars does not detect this format automatically. Since that's the case, I feel a bit hesitant to add it honestly.
Maybe let's sleep a bit on this and wait for Marco weighting on it

Copy link
Member

@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.

thanks for your PR (and @EdAbati + @FBruzzesi for reviews)

just got one really minor comment

regarding Polars, the datetime inference there is just based on trying out a bunch of hardcoded formats, and is probably ripe for being rewritten anyway

so i think we might as well go ahead with this

https://github.com/pola-rs/polars/blob/750b3712fa36046a9a2e35cdaddf5f767f3febab/crates/polars-time/src/chunkedarray/string/patterns.rs#L84-L151

HMS_RE = r"^(?P<hms>\d{2}:\d{2}:\d{2})$"
HM_RE = r"^(?P<hm>\d{2}:\d{2})$"
HMS_RE_NO_SEP = r"^(?P<hmsns>\d{6})$"
Copy link
Member

Choose a reason for hiding this comment

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

"ns" reads to me as "nanoseconds" here - maybe we can just write hms_no_sep?

@MarcoGorelli MarcoGorelli merged commit f676c35 into narwhals-dev:main Nov 10, 2024
20 of 22 checks passed
@raisadz raisadz deleted the pyarrow-add-format-nosep branch November 12, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enh]: Increase support for datetime format in pyarrow automatic inference
4 participants