-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Trying to access non-existent df column throws KeyError for wrong key #28799
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
Labels
Milestone
Comments
This looks fixed on master:
I guess this could use a regression test. |
Hi! I'd like to work on this as my first issue. You just need a regression test added to check that the proper KeyError is thrown? |
Correct. |
5 tasks
jreback
pushed a commit
that referenced
this issue
Oct 8, 2019
proost
pushed a commit
to proost/pandas
that referenced
this issue
Dec 19, 2019
proost
pushed a commit
to proost/pandas
that referenced
this issue
Dec 19, 2019
bongolegend
pushed a commit
to bongolegend/pandas
that referenced
this issue
Jan 1, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code Sample, a copy-pastable example if possible
I ran into this on a more complicated
groupby().apply(lambda: ...)
call, but reproduced a simple version below of what I think seems like a bug (or at least undesirable behavior).Doing this yields:
Problem description
When attempting to troubleshoot this,
KeyError: 'foo'
is misleading, as it doesn't point to the key that failed, but one that succeeded. In my actual code, I was doing this for more variables, so while this case is trivial to troubleshoot, real world cases might be more confusing and challenging to figure out for the user.Expected Output
A
KeyError: 'foo'
wherefoo
is the incorrect key, not a successful one.Output of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.4.final.0
python-bits : 64
OS : Linux
OS-release : 5.3.1-arch1-1-ARCH
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 0.25.1
numpy : 1.17.1
pytz : 2019.2
dateutil : 2.8.0
pip : 19.0.3
setuptools : 41.2.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.1
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.8.0
pandas_datareader: None
bs4 : 4.8.0
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.4.1
matplotlib : 3.1.1
numexpr : None
odfpy : None
openpyxl : 2.6.3
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.3.1
sqlalchemy : None
tables : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
The text was updated successfully, but these errors were encountered: