-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Series with MultiIndex "at" function raises "TypeError" #26989
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
Comments
Makes sense - if you'd like to take a look and submit a PR would certainly be welcome |
try this option: |
@Seemachopra22 That seems like a reasonable workaround, but I still think this is a bug that should be fixed. I'll work on a PR if I have time. |
I stumbled upon the same issue and did a little digging into the code. Please forgive any errors that are to follow - I am quite new to looking at the Pandas internals. It seems like the issue is line 2087 of this block of code within _ScalarAccessIndexer (similar issues for the getter methods): pandas/pandas/core/indexing.py Lines 2085 to 2091 in 844dc4a
When I run this on a series with a multi index, e.g.
self.ndim is 1 whereas key is ('x', 'y'), which leads to raising the value error. What I can't tell is whether self.ndim here should be 2, or if perhaps this check is not correct. |
If self.ndim is the same as pd.Series.ndim, then self.ndim must be 1 and I believe this check can be removed. |
Code Sample
Stack Trace:
Problem description
I would expect the
at
function to either return the values given by the indexers or raise aKeyError
. In the above example, the index value exists, soat
should return the value from the series at that index (nan
).The
at
function works fine for series with normal indexes. There is nothing in the documentation indicating it should not work for multi-indexes.Expected Output
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.7.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-50-generic
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: C.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.24.2
pytest: 3.4.2
pip: 19.1.1
setuptools: 41.0.1
Cython: 0.29.10
numpy: 1.16.4
scipy: 1.3.0
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.7.3
pytz: 2019.1
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
The text was updated successfully, but these errors were encountered: