-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
// we drop early as the brchk thinks the &str borrows are used when calling the drop | ||
// of both `columns` and `names` | ||
drop(names); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taken from
polars/crates/polars-core/src/frame/mod.rs
Lines 264 to 266 in 32df09e
// 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
There was a problem hiding this 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.
yup, thanks for your review! |
pivot
would introduce duplicate column names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
/// # 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> { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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?
closes #14305