Skip to content

Code for list of partial indexers should be in MultiIndex.get_indexer #27181

Open
@toobaz

Description

@toobaz

Code Sample, a copy-pastable example if possible

From #27180

In [5]: midx = pd.MultiIndex.from_product([[0, 1], [2, 3]])                                                                                                                                                                                   

In [6]: midx.get_loc(0)                                                                                                                                                                                                                       
Out[6]: slice(0, 2, None)

In [7]: midx.get_indexer([0])                                                                                                                                                                                                                 
Out[7]: array([-1])

Problem description

Indexing with lists of partial keys works (except for #18345 )

In [5]: midx = pd.MultiIndex.from_product([[0, 1], [2, 3]])                                                                                                                                                                                   

In [6]: midx.get_loc(0)                                                                                                                                                                                                                       
Out[6]: slice(0, 2, None)

In [7]: midx.get_indexer([0])                                                                                                                                                                                                                 
Out[7]: array([-1])

but it is not implemented in get_indexer() - where it should be.

Expected Output

slice(0, 2, None)

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 7ceefb3
python : 3.7.3.candidate.1
python-bits : 64
OS : Linux
OS-release : 4.9.0-9-amd64
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : it_IT.UTF-8
LOCALE : it_IT.UTF-8

pandas : 0.25.0.dev0+861.g7ceefb3f2.dirty
numpy : 1.16.4
pytz : 2016.7
dateutil : 2.8.0
pip : 9.0.1
setuptools : 41.0.1
Cython : 0.29.2
pytest : 4.6.3
hypothesis : 3.71.11
sphinx : 1.4.9
blosc : None
feather : None
xlsxwriter : 0.9.6
lxml.etree : 4.3.2
html5lib : 0.999999999
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.5.0
pandas_datareader: 0.2.1
bs4 : 4.5.3
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.3.2
matplotlib : 3.0.2
numexpr : 2.6.9
openpyxl : 2.3.0
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.1.0
sqlalchemy : 1.0.15
tables : 3.4.4
xarray : None
xlrd : 1.0.0
xlwt : 1.3.0
xlsxwriter : 0.9.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    IndexingRelated to indexing on series/frames, not to indexes themselvesMultiIndexRefactorInternal refactoring of code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions