Description
Code Sample, a copy-pastable example if possible
pandas.MultiIndex([[0],["a"]], [[0],[0]]).searchsorted((1,"b"))
Problem description
The entry (1,"b")
should come after the existing (0,"a")
in the MultiIndex
. (Alternatively, MultiIndex could throw a clean error message.) Instead, an intransparent exception is raised:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/site-packages/pandas/core/base.py", line 1156, in searchsorted
return self.values.searchsorted(key, side=side, sorter=sorter)
TypeError: unorderable types: tuple() > str()
This is because Index.searchsorted
naïvely passes its arguments to numpy.searchsorted
, which is unaware that its second argument is a sequence of tuples, not a plain array just of dimension one higher.
Expected Output
1
Output of pd.show_versions()
pandas: 0.19.1
nose: 1.3.7
pip: 9.0.1
setuptools: 28.8.0
Cython: 0.25.1
numpy: 1.11.2
scipy: None
statsmodels: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2016.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.3
openpyxl: None
xlrd: 1.0.0
xlwt: 0.8.0
xlsxwriter: None
lxml: None
bs4: 4.5.1
html5lib: 0.9999999
httplib2: 0.9.2
apiclient: None
sqlalchemy: 1.1.4
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None