pandas.HDFStore.put
pandas 3.1.1 · Input and output · method
Save a pandas object at a key in an HDFStore, replacing any existing value there.
Call syntax
HDFStore.put(…) Full signature
HDFStore.put(
key,
value,
format=None,
index=True,
append=False,
complib=None,
complevel=None,
min_itemsize=None,
nan_rep=None,
data_columns=None,
encoding=None,
errors='strict',
track_times=…,
dropna=…,
)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. |
value |
Required Positional or keyword |
{Series, DataFrame} Provide the value used for the documented operation, such as a replacement or a test point. |
format |
Optional Positional or keyword Default None |
'fixed(f)|table(t)' Supply a format string or choose an output layout supported by this API. |
index |
Optional Positional or keyword Default True |
bool Supply row labels or control how existing row labels are used. |
append |
Optional Positional or keyword Default False |
bool Add records or keys to existing output instead of replacing it where supported. |
complib |
Optional Positional or keyword Default None |
{'zlib', 'lzo', 'bzip2', 'blosc'} |
complevel |
Optional Positional or keyword Default None |
int, 0-9 |
min_itemsize |
Optional Positional or keyword Default None |
int, dict, or None |
nan_rep |
Optional Positional or keyword Default None |
str |
data_columns |
Optional Positional or keyword Default None |
list of columns or True |
encoding |
Optional Positional or keyword Default None |
str Name a text encoding such as "utf-8". |
errors |
Optional Positional or keyword Default 'strict' |
str Choose how to handle invalid input or failed operations. The available options depend on the API. |
track_times |
Optional Positional or keyword |
bool When omitted, the documented default is True. |
dropna |
Optional Positional or keyword |
bool Choose whether to drop missing values or missing keys from consideration. |
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.put("summary", frame[["units"]])
print(store.keys())