Skip to main content
`Ctrl`+`K`

# pandas.HDFStore.copy

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

  Copy the existing store to a new file, updating in place.

  Each object stored in the current `HDFStore` is 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:
    file str or path-like

      Destination file to write to.

    mode str, default ‘w’

      File mode for the destination, see `HDFStore`.

    propindexes bool, default True

      Restore indexes in copied file.

    keys list, optional

      List of keys to include in the copy (defaults to all).

    complib str, optional

      Compression library, see `HDFStore`.

    complevel int, optional

      Compression level, see `HDFStore`.

    fletcher32 bool, default False

      Whether to use the Fletcher32 checksum, see `HDFStore`.

    overwrite bool, 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.put`

    Write an object to the store.

  `HDFStore.append`

    Append 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()