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): is_first also supports numeric list type. #10727

Merged
merged 1 commit into from Aug 25, 2023

Conversation

reswqa
Copy link
Collaborator

@reswqa reswqa commented Aug 25, 2023

Since we already supported group_by list<T> where T has a numeric physical type. I assume it is easy to imp is_first.

The title may be a bit misleading, as it refers to the physical type being numerical rather than logical. So it actually supports a wider range of types.

@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 25, 2023
@reswqa reswqa marked this pull request as draft August 25, 2023 12:32
@reswqa reswqa marked this pull request as ready for review August 25, 2023 12:47
@@ -97,6 +113,11 @@ pub fn is_first(s: &Series) -> PolarsResult<BooleanChunked> {
},
#[cfg(feature = "dtype-struct")]
Struct(_) => return is_first_struct(&s),
#[cfg(feature = "group_by_list")]
List(inner) if inner.is_numeric() => {
Copy link
Collaborator Author

@reswqa reswqa Aug 25, 2023

Choose a reason for hiding this comment

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

if inner.is_numeric() here is for more friendly error message. If there is a List<Utf8> here, we will get InvalidOperationError: is_first operation not supported for dtype list[str] instead of ComputeError: "grouping on list type is only allowed if the inner type is numeric".

@ritchie46
Copy link
Member

Looks good. 👍

@ritchie46 ritchie46 merged commit 9ab5cdd into pola-rs:main Aug 25, 2023
30 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.

None yet

2 participants