BUG: Series.groupby fails with InvalidIndexError on time series with a tuple-named grouper. · Issue #42731 · pandas-dev/pandas (original) (raw)


Code Sample, a copy-pastable example

import pandas as pd

s = pd.Series(index=[pd.Timestamp(2021,7,26)], name=('A', 1)) s.groupby(s==s) # raises InvalidIndexError

Problem description

There are several things necessary to trigger this:

Why this is a problem: The name of a grouper should not matter and it is just not to understand why a time series behaves differently than any other kind of Series.

Expected Output

Behavior should be as for non-time-series.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : db08276
python : 3.8.3.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 13, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : de_DE.cp1252
pandas : 1.1.3
numpy : 1.20.3
pytz : 2021.1
dateutil : 2.8.2
pip : 21.1.3
setuptools : 52.0.0.post20210125
Cython : None
pytest : 6.2.4
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : 1.3.2
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : 2.7.3
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None