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

Consider making the DataFrame API less verbose by imitating Polars #4890

Open
oersted opened this issue Jan 13, 2023 · 1 comment
Open

Consider making the DataFrame API less verbose by imitating Polars #4890

oersted opened this issue Jan 13, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@oersted
Copy link

oersted commented Jan 13, 2023

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

I'd say that, for instance, .select(["name"]) is significantly easier to read and write than .select(vec![col("name")]).

Describe the solution you'd like

Polars deals with this by having the following more generic signature.

pub fn select<I, S>(&self, selection: I) -> Result<DataFrame, PolarsError>
where
    I: IntoIterator<Item = S>,
    S: AsRef<str>

IntoIterator makes a lot of sense, it allows for arrays for concise syntax and Vec or any other collection whenever the list is programmatically generated.

AsRef<str> is less clear, I'm not sure how they refer to complex expressions with a string reference. Perhaps Into<Expr> might be better with a default implementation for &str.

Yes I know that there's also a select_columns(&self, columns: &[&str]) method in the current API, but it is still less flexible, somewhat redundant, and there are other places where vec! and col() somewhat pollute the syntax still.

@oersted oersted added the enhancement New feature or request label Jan 13, 2023
@alamb
Copy link
Contributor

alamb commented Jan 15, 2023

I agree this would be a great change ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants