Skip to content

Commit

Permalink
Move frame error message
Browse files Browse the repository at this point in the history
  • Loading branch information
mcrumiller committed Feb 13, 2024
1 parent a3f3489 commit a836380
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 1 addition & 8 deletions crates/polars-core/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1536,14 +1536,7 @@ impl DataFrame {
let mut names = PlHashSet::with_capacity(cols.len());
for name in cols {
if !names.insert(name.as_str()) {
let msg = format!(
"the name: '{}' passed to `select` is duplicate\n\n\
It's possible that multiple expressions are returning the same default column name. \
If this is the case, try renaming the columns with `.alias(\"new_name\")` to avoid \
duplicate column names.",
name
);
return Err(PolarsError::ComputeError(msg.into()));
polars_bail!(duplicate = name);
}
}
Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,17 @@ pub(super) fn check_expand_literals(
all_equal_len = false;
}
let name = s.name();
polars_ensure!(names.insert(name), duplicate = name);

if !names.insert(name) {
let msg = format!(
"the name: '{}' passed to `select` is duplicate\n\n\
It's possible that multiple expressions are returning the same default column \
name. If this is the case, try renaming the columns with \
`.alias(\"new_name\")` to avoid duplicate column names.",
name
);
return Err(PolarsError::Duplicate(msg.into()));
}
}
}
// If all series are the same length it is ok. If not we can broadcast Series of length one.
Expand Down

0 comments on commit a836380

Please sign in to comment.