Description
Code Sample, a copy-pastable example if possible
df = pd.DataFrame({
"x": pd.Categorical(["a", "b", "c"]),
"y": [10, 20, 30]}
).set_index("x")
print(df.index)
print(df.loc["a"]["y"])
print(df.at["a", "y"])
Problem description
Loc works using a categorical index, at does not.
Both should work.
Expected Output
CategoricalIndex(['a', 'b', 'c'], categories=['a', 'b', 'c'], ordered=False, name='x', dtype='category')
10
10
Actual output
CategoricalIndex(['a', 'b', 'c'], categories=['a', 'b', 'c'], ordered=False, name='x', dtype='category')
10
Traceback (most recent call last):
File "test.py", line 9, in <module>
print(df.at["a", "y"])
File "/rose/temp/shu/pandas/pandas/core/indexing.py", line 2277, in __getitem__
return self.obj._get_value(*key, takeable=self._takeable)
File "/rose/temp/shu/pandas/pandas/core/frame.py", line 2720, in _get_value
return engine.get_value(series._values, index)
File "pandas/_libs/index.pyx", line 81, in pandas._libs.index.IndexEngine.get_value
File "pandas/_libs/index.pyx", line 89, in pandas._libs.index.IndexEngine.get_value
File "pandas/_libs/index.pyx", line 129, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index_class_helper.pxi", line 214, in pandas._libs.index.Int8Engine._check_type
Output of pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-134-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.25.0.dev0+321.gb878f5b
pytest: None
pip: 19.0.1
setuptools: 40.8.0
Cython: 0.29.6
numpy: 1.16.2
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: 1.8.5
patsy: None
dateutil: 2.8.0
pytz: 2018.9
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
Traceback (most recent