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: allow format=None in str.to_datetime #1145

Merged
merged 3 commits into from
Oct 7, 2024
Merged

Conversation

FBruzzesi
Copy link
Member

@FBruzzesi FBruzzesi commented Oct 6, 2024

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

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

Checklist

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

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

Opening as draft since (Ok I misscliked) pyarrow is unsupported and may need some discussion for how to achieve it.

For context, this is the snippet in plotly that requires casting to datetime: process_dataframe_timeline

@github-actions github-actions bot added enhancement New feature or request labels Oct 6, 2024
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 @FBruzzesi !

just a thought - it looks like here there's a pure-python solution to inferring a format

maybe, in plotly, they could do something like:

  • if it's pandas-like or polars, use to_datetime with format=None
  • else, take the first non-null element, get the format using the solution above, and try to parse using that?

just an idea - not a blocker for this pr anyway!

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.

@FBruzzesi
Copy link
Member Author

just a thought - it looks like here there's a pure-python solution to inferring a format

  • if it's pandas-like or polars, use to_datetime with format=None
  • else, take the first non-null element, get the format using the solution above, and try to parse using that?

Shall we consider doing that in narwhals for pyarrow backend and null format? I think it can be a quite common use case for anything related with timeseries.

@MarcoGorelli
Copy link
Member

yeah sure!

@FBruzzesi
Copy link
Member Author

Merging this one as is for now and will come back to the arrow dedicate branch in another PR

@FBruzzesi FBruzzesi merged commit 0bcb9a9 into main Oct 7, 2024
28 checks passed
@FBruzzesi FBruzzesi deleted the feat/to-datetime-kws branch October 7, 2024 19:17
akmalsoliev pushed a commit to akmalsoliev/narwhals that referenced this pull request Oct 15, 2024
* WIP

* allow str.to_datetime with format=None
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.

2 participants