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): add utc parameter to strptime #6496

Merged
merged 3 commits into from
Jan 28, 2023

Conversation

MarcoGorelli
Copy link
Collaborator

closes #6466

demo:

In [3]: ts = ['2021-03-27T23:59:59+01:00', '2021-03-28T23:59:59+02:00']

In [4]: pd.Series(pd.to_datetime(ts, utc=True))
Out[4]: 
0   2021-03-27 22:59:59+00:00
1   2021-03-28 21:59:59+00:00
dtype: datetime64[ns, UTC]

In [5]: pl.Series(ts).str.strptime(pl.Datetime, '%+', utc=True)
Out[5]: 
shape: (2,)
Series: '' [datetime[μs, UTC]]
[
        2021-03-27 22:59:59 UTC
        2021-03-28 21:59:59 UTC
]

@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 Jan 27, 2023
@MarcoGorelli MarcoGorelli marked this pull request as ready for review January 27, 2023 15:37
Copy link

@FObersteiner FObersteiner left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you for implementing this :)

A small detail you might add: see my comment on the ComputeError.

Some(tz_found) => {
if tz_found != dt.timezone() {
return Err(PolarsError::ComputeError(
"Different timezones found during 'strptime' operation.".into(),

Choose a reason for hiding this comment

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

This error might now hint to using utc=True

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good one, thanks!

@ritchie46
Copy link
Member

Thanks a lot @MarcoGorelli and @FObersteiner. Great addition. :)

@ritchie46 ritchie46 merged commit dfca44c into pola-rs:master Jan 28, 2023
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.

utc parameter in strptime
3 participants