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(rust, python): improve datetime parsing error message #10332

Merged
merged 3 commits into from
Aug 7, 2023

Conversation

MarcoGorelli
Copy link
Collaborator

@MarcoGorelli MarcoGorelli commented Aug 7, 2023

Demo

On main:

In [1]: pl.Series(['2020-01-01', '2020-01-o2']).str.to_date()
---------------------------------------------------------------------------
ComputeError: strict date parsing failed for 1 value(s) (1 unique): ["2020-01-o2"]

You might want to try:
- setting `strict=False`
- explicitly specifying a `format`

In [2]: pl.Series(['2020-01-01', '2020-01-o2']).str.to_date(format='%Y-%m-%d')
---------------------------------------------------------------------------
ComputeError: strict date parsing failed for 1 value(s) (1 unique): ["2020-01-o2"]

You might want to try:
- setting `strict=False`
- explicitly specifying a `format`

In [3]: pl.Series(['00:00', '00:0l']).str.to_time(format='%H:%M')
---------------------------------------------------------------------------
ComputeError: strict time parsing failed for 1 value(s) (1 unique): ["00:0l"]

You might want to try:
- setting `strict=False`
- explicitly specifying a `format`

Here:

In [1]: pl.Series(['2020-01-01', '2020-01-o2']).str.to_date()
---------------------------------------------------------------------------
ComputeError: strict date parsing failed for 1 value(s) (1 unique): ["2020-01-o2"]

You might want to try:
- setting `strict=False`
- setting `exact=False` (note: this is much slower!)
- explicitly specifying `format`

In [2]: pl.Series(['2020-01-01', '2020-01-o2']).str.to_date(format='%Y-%m-%d')
---------------------------------------------------------------------------
ComputeError: strict date parsing failed for 1 value(s) (1 unique): ["2020-01-o2"]

You might want to try:
- setting `strict=False`
- setting `exact=False` (note: this is much slower!)
- checking whether the format provided ('%Y-%m-%d') is correct

In [3]: pl.Series(['00:00', '00:0l']).str.to_time(format='%H:%M')
---------------------------------------------------------------------------
ComputeError: strict time parsing failed for 1 value(s) (1 unique): ["00:0l"]

You might want to try:
- setting `strict=False`
- checking whether the format provided ('%H:%M') is correct

@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 Aug 7, 2023
@MarcoGorelli MarcoGorelli marked this pull request as ready for review August 7, 2023 09:21
@ritchie46
Copy link
Member

Very nice!

@MarcoGorelli
Copy link
Collaborator Author

thanks! 🙏

@MarcoGorelli MarcoGorelli merged commit fda5e26 into pola-rs:main Aug 7, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

2 participants