Closed
Description
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
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
jreback commentedon Dec 16, 2016
This is indicated in the doc-string.
however, would be willing to add a
errors='ignore'|'raise'
argument to control this. So will mark this as an enhancement.[-]DataFrame.rename doesn't error out when it receives an unknown column name[/-][+]ENH: add errors=ignore|raise kw to DataFrame.rename[/+]TomAugspurger commentedon Dec 16, 2016
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.