Groupby crash on a single level · Issue #30208 · pandas-dev/pandas (original) (raw)
Code Sample, a copy-pastable example if possible
test = pd.DataFrame({ 'COL1': [1] }, index=[0])
test.columns.name = 'COL' test.columns.names = ['COL']
test.groupby(axis=1, level='COL')
Problem description
/opt/research-maintainer/cfm/1901-py3/lib/python3.6/site-packages/pandas/core/groupby.py in _get_grouper(obj, key, axis, level, sort, mutated, validate) 2828 if obj.index.name != level: 2829 raise ValueError('level name %s is not the name of the ' -> 2830 'index' % level) 2831 elif level > 0 or level < -1: 2832 raise ValueError('level > 0 or level < -1 only valid with '
ValueError: level name COL is not the name of the index
Expected Output
Not crashing I think?
Output of pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.8.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.32-642.6.2.el6.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.21.1
pytest: 4.4.1
pip: 9.0.1
setuptools: 28.8.0
Cython: 0.27.3
numpy: 1.13.3
scipy: 0.19.1
pyarrow: 0.13.0
xarray: 0.8.2
IPython: 5.1.0
sphinx: 1.4.4
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.4.4
numexpr: 2.6.5
feather: None
matplotlib: 2.1.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: 0.9999999
sqlalchemy: 1.2.18
pymysql: None
psycopg2: None
jinja2: 2.8
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None