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

alias function for pd.Series #1449

Closed
samukweku opened this issue Mar 1, 2025 · 0 comments · Fixed by #1451
Closed

alias function for pd.Series #1449

samukweku opened this issue Mar 1, 2025 · 0 comments · Fixed by #1451

Comments

@samukweku
Copy link
Collaborator

Brief Description

I would like to propose pd.Series.alias(new name) to allow for convenient renaming of a Series.
This comes in handy when renaming within a function, and allow for changing a Series name via a callable.
pd.Series.rename only changes the name if a scalar is passed; if a callable is passed, it is passed to the index labels, not the name of the Series. alias works only on the name, not the index labels.

Example API

series = pd.Series({'a':[1,2,3]})
series.alias('new_name')
series.alias(str.lower)
series.alias(lambda s: f"{s}_mean")
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 a pull request may close this issue.

1 participant