BUG:Tuple Series name causes InvalidIndexError in Pandas 1.2.4 but not in 0.25.3 #42966
Closed
2 of 3 tasks
Labels
Bug
Duplicate Report
Duplicate issue or pull request
Groupby
Indexing
Related to indexing on series/frames, not to indexes themselves
Regression
Functionality that used to work in a prior pandas version
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Problem description
I pass the
groupby
function aby
parameter which is series whose name is a Tuple. In older pandas (0.25.3), this worked. In modern (1.2.4) pandas this raises anInvalidIndexError
.You might say, "well then don't name your series with Tuple, name it with a string." How my situation happens in real-life is that I'm taking a
.loc
slice of aDataFrame
with multilevel columns. This returns a Series, and its name is automatically a tuple of the column levels. I can do a gross temporary-rename of the series, but feels like a hack.Expected Output
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2cb9652
python : 3.9.4.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_Singapore.1252
pandas : 1.2.4
numpy : 1.20.1
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 52.0.0.post20210125
Cython : 0.29.23
pytest : 6.2.3
hypothesis : None
sphinx : 4.0.1
blosc : None
feather : None
xlsxwriter : 1.3.8
lxml.etree : 4.6.3
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.22.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 0.9.0
fastparquet : None
gcsfs : None
matplotlib : 3.3.4
numexpr : 2.7.3
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.6.2
sqlalchemy : 1.4.7
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 2.0.1
xlwt : 1.3.0
numba : 0.53.1
The text was updated successfully, but these errors were encountered: