-
Notifications
You must be signed in to change notification settings - Fork 1
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
key error for query with empty result #29
Comments
Hm, but that is what I would expect, no? |
We could have our own class |
Compare what we do with what pandas does: In [1]: import pandas as pd
In [3]: df = pd.DataFrame([{"a": 2, "b": 3}, {"a": 4, "b": 12}], index=["first", "second"])
In [4]: df
Out[4]:
a b
first 2 3
second 4 12
In [5]: df.loc["third"]
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/.local/lib/python3.9/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
3360 try:
-> 3361 return self._engine.get_loc(casted_key)
3362 except KeyError as err:
~/.local/lib/python3.9/site-packages/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
~/.local/lib/python3.9/site-packages/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'third' |
My problems with the current key error are |
True, KeyError for |
I think an error is best as empty dataframes can also pose problems when working with them so the error would just occur a bit later. |
Description
When using query (single category interface) and there is no data available a key error is thrown instead of returning an empty dataframe or "None" or a message saying that there are no results.
What I Did
The text was updated successfully, but these errors were encountered: