You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pandas allows a mapping to be passed like df.rename(columns={'foo': 'bar'}). This is often very useful when you only want to rename a subset of the columns. Currently, rename_columns only accepts a list of all column names.
I propose that rename_columns be extended to accept a Mapping[str, str]. All columns with a name matching a key of the mapping will be renamed to the relevant value. If any key does not correspond to at least one column then a KeyError should be raised.
…_columns` (#40645)
### Rationale for this change
See #40644
### What changes are included in this PR?
### Are these changes tested?
Yes.
Tests have been added.
### Are there any user-facing changes?
* GitHub Issue: #40644
Authored-by: Judah Rand <[email protected]>
Signed-off-by: AlenkaF <[email protected]>
…rename_columns` (apache#40645)
### Rationale for this change
See apache#40644
### What changes are included in this PR?
### Are these changes tested?
Yes.
Tests have been added.
### Are there any user-facing changes?
* GitHub Issue: apache#40644
Authored-by: Judah Rand <[email protected]>
Signed-off-by: AlenkaF <[email protected]>
vibhatha
pushed a commit
to vibhatha/arrow
that referenced
this issue
May 25, 2024
…rename_columns` (apache#40645)
### Rationale for this change
See apache#40644
### What changes are included in this PR?
### Are these changes tested?
Yes.
Tests have been added.
### Are there any user-facing changes?
* GitHub Issue: apache#40644
Authored-by: Judah Rand <[email protected]>
Signed-off-by: AlenkaF <[email protected]>
Describe the enhancement requested
Pandas allows a mapping to be passed like
df.rename(columns={'foo': 'bar'})
. This is often very useful when you only want to rename a subset of the columns. Currently,rename_columns
only accepts a list of all column names.I propose that
rename_columns
be extended to accept aMapping[str, str]
. All columns with a name matching a key of the mapping will be renamed to the relevant value. If any key does not correspond to at least one column then aKeyError
should be raised.Example:
Component(s)
Python
The text was updated successfully, but these errors were encountered: