pandas.HDFStore.create_table_index
pandas 3.1.1 · Input and output · method
Build a PyTables index on stored columns for indexed queries.
Call syntax
HDFStore.create_table_index(key, columns=None, optlevel=None, kind=None)Inspect the call
Run this code to inspect the callable and its parameters. Its data, backend, or environment is needed to execute the operation itself.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
key |
Required Positional or keyword |
str Provide the lookup key, or a transformation callable for a sorting method. |
columns |
Optional Positional or keyword Default None |
None, bool, or listlike[str] Supply column labels or control how columns are handled. |
optlevel |
Optional Positional or keyword Default None |
int or None |
kind |
Optional Positional or keyword Default None |
str or None Choose the implementation variant, such as a sort algorithm or a plot type. |
Returns
None
Example for a local Python session
import pandas as pd
from pathlib import Path
from tempfile import TemporaryDirectory
import tables
frame = pd.DataFrame({"units": [2, 5], "price": [4, 3]})
with TemporaryDirectory() as folder:
path = Path(folder) / "demo.h5"
with pd.HDFStore(path, mode="w") as store:
store.put("orders", frame, format="table", data_columns=["units"])
store.create_table_index("orders", columns=["units"])
print(store.select("orders", where="units > 2"))