Description
Today I've found weird behaviour of level parameter of groupby. I need to groupby two dataframes by index and this code is working as long as I'm using Multiindex.
index1 = pandas.Index([1,2,3,4,5])
index2 = pandas.Index([1,2,3,4,5])
first = pandas.DataFrame({'a':[1,2,3,4,5]}, index=index1)
second = df2 = pandas.DataFrame({'a':[2,3,4,5,6]}, index=index2)
pandas.concat([first, second]).groupby(level=range(first.index.nlevels)).min()
Unfortunately when I'm using simple Index I get:
ValueError: level > 0 only valid with MultiIndex
In other way if I passed 0 instead of [0], everything is working properly. It's weird and cause that it's hard to write reusable code.
INSTALLED VERSIONS
commit: None
python: 2.7.12.final.0
python-bits: 64
OS: Linux
OS-release: 4.2.0-42-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF8
pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 20.3
Cython: None
numpy: 1.11.1
scipy: None
statsmodels: None
xarray: None
IPython: 4.2.0
sphinx: None
patsy: None
dateutil: 2.4.1
pytz: 2016.4
blosc: None
bottleneck: 1.1.0
tables: 3.2.2
numexpr: 2.6.0
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: 1.1.2
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: None
boto: None
pandas_datareader: None