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

refactor: rename to with_column_renamed to rename #908

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ion-elgreco
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Simpler API that allows multiple renames instead of having to chain .with_column_renamed.

What changes are included in this PR?

  • adds a rename method which in Rust calls with_column_renamed. I can look into adding a native rename in datafusion rust eventually.
  • deprecates with_column_renamed

Are there any user-facing changes?

  • deprecates with_column_renamed

python/datafusion/dataframe.py Outdated Show resolved Hide resolved
Comment on lines +183 to +184
def rename(self, mapping: dict[str, str]) -> DataFrame:
r"""Rename one or multiple columns by applying a new projection.
Copy link
Contributor

Choose a reason for hiding this comment

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

How about with_columns_renamed to be more clear what this is doing? I could imagine users confusing this changing a table's name, even though the dataframe doesn't have a name associated with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would argue rename is quite clear if you are acquainted with pandas and pola-rs API.

With columns renamed is quite verbose ^^

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to hear other people's opinions. Also I don't recommend we stray too far from what the upstream DataFusion uses for naming conventions.

python/datafusion/dataframe.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants