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: Raise if pivot would introduce duplicate column names #14431

Merged
merged 4 commits into from
Feb 12, 2024

Conversation

MarcoGorelli
Copy link
Collaborator

@MarcoGorelli MarcoGorelli commented Feb 12, 2024

closes #14305

@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 Feb 12, 2024
Comment on lines +431 to +433
// we drop early as the brchk thinks the &str borrows are used when calling the drop
// of both `columns` and `names`
drop(names);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

taken from

// we drop early as the brchk thinks the &str borrows are used when calling the drop
// of both `series_cols` and `names`
drop(names);

I wouldn't have thought of this

Copy link
Member

@stinodego stinodego 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, just some small comments.

crates/polars-core/src/frame/mod.rs Outdated Show resolved Hide resolved
crates/polars-core/src/frame/mod.rs Outdated Show resolved Hide resolved
@MarcoGorelli MarcoGorelli marked this pull request as draft February 12, 2024 17:49
@MarcoGorelli MarcoGorelli marked this pull request as ready for review February 12, 2024 18:19
@MarcoGorelli
Copy link
Collaborator Author

yup, thanks for your review!

@stinodego stinodego changed the title feat: raise if pivot would introduce duplicate column names feat: Raise if pivot would introduce duplicate column names Feb 12, 2024
Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

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

Great!

stinodego

This comment was marked as duplicate.

@stinodego stinodego merged commit dd89800 into pola-rs:main Feb 12, 2024
23 checks passed
/// # Panic
/// It is the callers responsibility to uphold the contract of all `Series`
/// having an equal length, if not this may panic down the line.
pub fn new_no_length_checks(columns: Vec<Series>) -> PolarsResult<DataFrame> {
Copy link
Member

Choose a reason for hiding this comment

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

This should be tagged unsafe as it doesn't check the invariant of DataFrame.

Copy link
Member

@stinodego stinodego Feb 12, 2024

Choose a reason for hiding this comment

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

I can make a quick patch! For reference, the new_no_checks method has the following signature:

pub const fn new_no_checks(columns: Vec<Series>) -> DataFrame

Is this correct or should that also be tagged unsafe?

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.

pivot may still introduce duplicate column names (in a different way!)
3 participants