pandas.HDFStore.copy

pandas 3.1.1 · Input and output · method

Copy stored pandas objects to another HDF5 file, optionally selecting keys.

Call syntax

HDFStore.copy(…) Full signature
HDFStore.copy(
    file,
    mode='w',
    propindexes=True,
    keys=None,
    complib=None,
    complevel=None,
    fletcher32=False,
    overwrite=True,
)

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

ParameterRequirementAccepted values and behavior
file Required
Positional or keyword
str or path-like
mode Optional
Positional or keyword
Default 'w'
str

Choose a file or storage access mode.

propindexes Optional
Positional or keyword
Default True
bool
keys Optional
Positional or keyword
Default None
list

Provide grouping, dictionary, index, or concatenation keys for this operation.

complib Optional
Positional or keyword
Default None
str
complevel Optional
Positional or keyword
Default None
int
fletcher32 Optional
Positional or keyword
Default False
bool
overwrite Optional
Positional or keyword
Default True
bool

Choose whether existing entries can be replaced.

Returns

HDFStore

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"])
        with store.copy(Path(folder) / "copy.h5") as copy:
            print(copy.keys())