Description
-
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
import pandas as pd
if __name__ == "__main__":
series = pd.Series([1, 2, 3, 4], index=[("a", ), ("b", ), ("c", ), ("d", )])
print(series[("a", )])
Problem description
On pandas 1.0.5 selecting values of a series which is indexed by tuples was possible via __getitem__
using the desired tuple (see above code). In pandas 1.1.0 this suddenly raises a ValueError:
ValueError: Can only tuple-index with a MultiIndex
As this used to work in 1.0.5 and earlier versions (0.25 as far as I can recall) I expect this to be an unwanted side effect rather than a wanted change in behavior (in which case it would certainly be breaking).
Apart from this, I expected Series objects to behave to some degree like python dictionaries. In particular using tuples of strings as keys and selecting values by such tuples I think should be possible.
Expected Output
1
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit : d9fff2792bf16178d4e450fe7384244e50635733
python : 3.8.3.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-42-generic
Version : #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.0
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 47.3.1.post20200622
Cython : None
pytest : None
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 : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
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
None