Skip to content

DOC: HDFStore.select documentation miss information about selecting MultiIndex #28791

Closed
@nrebena

Description

@nrebena

Code Sample

import pandas as pd 
index = pd.MultiIndex.from_product([['a', 'b'], [1, 2]]) 
df = pd.DataFrame(range(4), index=index) 
store = pd.HDFStore('store.h5') 
store.append('dataframe', df) 
store.select('dataframe', where="level_0 in 'b' and level_1 in 2")         
                                                     
Out[3]: 
     0
b 2  3

Problem description

When using a MultiIndex in a HDFStore, you can select from the MultiIndex using the keyword level_0, level_1, …
This behaviour is not yet documented in the user guide.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit : 02675e3 python : 3.7.4.final.0 python-bits : 64 OS : Linux OS-release : 5.3.1-arch1-1-ARCH machine : x86_64 processor : byteorder : little LC_ALL : None LANG : fr_FR.UTF-8 LOCALE : fr_FR.UTF-8

pandas : 0.26.0.dev0+446.g02675e337.dirty
numpy : 1.16.3
pytz : 2019.1
dateutil : 2.8.0
pip : 19.0.3
setuptools : 40.8.0
Cython : 0.29.13
pytest : 4.4.1
hypothesis : 4.18.2
sphinx : 1.8.5
blosc : 1.8.1
feather : None
xlsxwriter : 1.1.7
lxml.etree : 4.3.3
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.5.0
pandas_datareader: None
bs4 : 4.7.1
bottleneck : 1.2.1
fastparquet : 0.3.1
gcsfs : None
lxml.etree : 4.3.3
matplotlib : 3.0.3
numexpr : 2.6.9
odfpy : None
openpyxl : 2.6.2
pandas_gbq : None
pyarrow : 0.13.0
pytables : None
s3fs : 0.2.1
scipy : 1.2.1
sqlalchemy : 1.3.3
tables : 3.5.1
xarray : 0.12.1
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.1.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions