pandas.HDFStore.copy#
- HDFStore.copy(file, mode='w', propindexes=True, keys=None, complib=None, complevel=None, fletcher32=False, overwrite=True)[source]#
Copy the existing store to a new file, updating in place.
Each object stored in the current
HDFStoreis read and re-written to the destination file, which can be useful for repacking (to reclaim space after deletes), changing compression options, or cloning a subset of keys.- Parameters:
- filestr or path-like
Destination file to write to.
- modestr, default ‘w’
File mode for the destination, see
HDFStore.- propindexesbool, default True
Restore indexes in copied file.
- keyslist, optional
List of keys to include in the copy (defaults to all).
- complibstr, optional
Compression library, see
HDFStore.- complevelint, optional
Compression level, see
HDFStore.- fletcher32bool, default False
Whether to use the Fletcher32 checksum, see
HDFStore.- overwritebool, default True
Whether to overwrite (remove and replace) existing nodes in the new store.
- Returns:
- HDFStore
Open file handle of the new store.
See also
HDFStore.putWrite an object to the store.
HDFStore.appendAppend to an existing table.
Examples
>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"]) >>> store = pd.HDFStore("store.h5", "w") >>> store.put("data", df) >>> new_store = store.copy("store_copy.h5") >>> new_store.close() >>> store.close()