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

ENH: add errors=ignore|raise kw to DataFrame.rename #14896

Closed
rahulporuri opened this issue Dec 16, 2016 · 2 comments
Closed

ENH: add errors=ignore|raise kw to DataFrame.rename #14896

rahulporuri opened this issue Dec 16, 2016 · 2 comments
Labels
API Design Duplicate Report Duplicate issue or pull request Enhancement Indexing Related to indexing on series/frames, not to indexes themselves

Comments

@rahulporuri
Copy link

Code Sample, a copy-pastable example if possible

import pandas
df = pandas.DataFrame({'a': [1,2], 'b': [3,4]})
df.rename({'C':'D'})

Problem description

I expected the method to throw an error, complaining that the key passed via
the dictionary isnt a valid column name in the DataFrame. Instead, nothing happens.

Expected Output

some sort of error.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 2.7.12.final.0 python-bits: 64 OS: Darwin OS-release: 16.1.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 LOCALE: None.None

pandas: 0.19.0
nose: None
pip: 9.0.1
setuptools: 23.1.0
Cython: None
numpy: 1.10.4
scipy: None
statsmodels: None
xarray: None
IPython: 4.1.2
sphinx: None
patsy: None
dateutil: 2.5.2
pytz: 2016.3
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None

@jreback
Copy link
Contributor

jreback commented Dec 16, 2016

This is indicated in the doc-string.

Signature: df.rename(index=None, columns=None, **kwargs)
Docstring:
Alter axes input function or functions. Function / dict values must be
unique (1-to-1). Labels not contained in a dict / Series will be left
as-is. Extra labels listed don't throw an error. Alternatively, change
``Series.name`` with a scalar value (Series only).

however, would be willing to add a errors='ignore'|'raise' argument to control this. So will mark this as an enhancement.

@jreback jreback added API Design Difficulty Novice Enhancement Indexing Related to indexing on series/frames, not to indexes themselves labels Dec 16, 2016
@jreback jreback added this to the Next Major Release milestone Dec 16, 2016
@jreback jreback changed the title DataFrame.rename doesn't error out when it receives an unknown column name ENH: add errors=ignore|raise kw to DataFrame.rename Dec 16, 2016
@TomAugspurger
Copy link
Contributor

Dupe of #13473. I think the decision there was to add a keyword errors={'ignore' | 'raise'}, with the default being ignore.

@rahulporuri if you're interested in submitting a fix, we'd appreciate it.

@TomAugspurger TomAugspurger added the Duplicate Report Duplicate issue or pull request label Dec 16, 2016
@TomAugspurger TomAugspurger modified the milestones: No action, Next Major Release Dec 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Duplicate Report Duplicate issue or pull request Enhancement Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

No branches or pull requests

3 participants