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(python): allow df.rename and lf.rename to take a renaming function #13708

Merged
merged 4 commits into from
Jan 19, 2024

Conversation

Wainberg
Copy link
Contributor

Closes #13229.

There seemed to be a lot of popular demand for this (based on the number of likes on the original issue), so I went ahead and implemented it.

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Jan 13, 2024
Copy link
Collaborator

@alexander-beedie alexander-beedie left a comment

Choose a reason for hiding this comment

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

Nice - I think the idea makes sense, and the use of pl.all().name.map looks clean; good stuff! A few minor comments, and then can you add some unit tests? Would help to see it in action to validate behaviour. Once the nits are dealt with and there is some code coverage I'll approve 👍

@Wainberg
Copy link
Contributor Author

@alexander-beedie just added a couple of tests. Did you mean to leave comments on the code as well?

@Wainberg
Copy link
Contributor Author

@alexander-beedie how's this looking, would you say it's ready to merge?

@alexander-beedie
Copy link
Collaborator

alexander-beedie commented Jan 19, 2024

@alexander-beedie how's this looking, would you say it's ready to merge?

I don't see that you've addressed the inline comments yet?
Once they're handled, then "yes" ;)

@Wainberg
Copy link
Contributor Author

@alexander-beedie you'll have to forgive me if I'm being thick, but I don't see any comments. Usually they'd appear in the conversation tab, but here's what the conversation tab looks like for me:

image

and here's the files changed tab:

image

@orlp
Copy link
Collaborator

orlp commented Jan 19, 2024

@Wainberg I don't think you're being thick, I can't see them either.

@alexander-beedie Could you re-post those comments?

py-polars/polars/dataframe/frame.py Outdated Show resolved Hide resolved
py-polars/polars/dataframe/frame.py Outdated Show resolved Hide resolved
@alexander-beedie
Copy link
Collaborator

alexander-beedie commented Jan 19, 2024

@alexander-beedie Could you re-post those comments?

Ouch; I blame the GitHub UI for that one; I could see them marked as "Pending", which I thought was "pending action by the author of the PR", but apparently means "Pending you hitting the 'submit' button so the author can see them", sigh... Apologies for that one @Wainberg; think they should be visible now 🤣

@Wainberg
Copy link
Contributor Author

@alexander-beedie No worries! Just made the two changes you suggested.

@alexander-beedie alexander-beedie merged commit 62ecdd3 into pola-rs:main Jan 19, 2024
11 checks passed
@alexander-beedie
Copy link
Collaborator

Looks good to me 👌

@Wainberg Wainberg deleted the rename-function branch January 19, 2024 18:00
r-brink pushed a commit to r-brink/polars that referenced this pull request Jan 24, 2024
…on (pola-rs#13708)

Co-authored-by: Wainberg <m.wainberg@utoronto.ca>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow df.rename() to take a function that maps old to new column names
3 participants