Skip to main content
`Ctrl`+`K`

# pandas.HDFStore.put

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=<no_default>, dropna=<no_default>)

  Store object in HDFStore.

  This method writes a pandas DataFrame or Series into an HDF5 file using either the fixed or table format. The table format allows additional operations like incremental appends and queries but may have performance trade-offs. The fixed format provides faster read/write operations but does not support appends or queries.

  Parameters:
    key str

      Key of object to store in file.

    value{Series, DataFrame}

      Value of object to store in file.

    format‘fixed(f)|table(t)’, default is ‘fixed’

      Format to use when storing object in HDFStore. Value can be one of:

      `'fixed'`

        Fixed format. Fast writing/reading. Not-appendable, nor searchable.

      `'table'`

        Table format. Write as a PyTables Table structure which may perform worse but allow more flexible operations like searching / selecting subsets of the data.

    index bool, default True

      Write DataFrame index as a column.

    append bool, default False

      This will force Table format, append the input data to the existing.

    complib{‘zlib’, ‘lzo’, ‘bzip2’, ‘blosc’}, default None

      Compression library to use, only applied with `format='table'`. None disables compression. See the `complib` parameter of `HDFStore` for the full list of supported compressors.

    complevel int, 0-9, default None

      Specifies a compression level for data. A value of 0 or None disables compression.

    min_itemsize int, dict, or None

      Minimum number of bytes reserved for object columns. If int, all columns reserve ‘min_itemsize’ bytes per stored value. If dict, specific columns reserve ‘min_itemsize’ bytes per stored value. Strings are stored as encoded bytes. Since some characters require multiple bytes, required size may be larger than string length.

    nan_rep str, default ‘nan’

      Str to use as str nan representation.

    data_columns list of columns or True, default None

      List of columns to create as data columns, or True to use all columns. See here.

    encoding str, default None

      Provide an encoding for strings.

    errors str, default ‘strict’

      The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

    track_times bool, default True

      Parameter is propagated to ‘create_table’ method of ‘PyTables’. If set to False it enables to have the same h5 files (same hashes) independent on creation time.

      Deprecated since version 3.1.0: The default value of `track_times` will change from `True` to `False` in a future version. Pass `track_times=False` explicitly to silence this warning and get deterministic HDF5 files.

    dropna bool, default False, optional

      Remove missing values.

      Deprecated since version 3.1.0: The `dropna` keyword is deprecated and will be removed in a future version. Use `DataFrame.dropna()` before writing instead.

  See also

  `HDFStore.info`

    Prints detailed information on the store.

  `HDFStore.get_storer`

    Returns the storer object for a key.

  Notes

  Writing an empty `DataFrame` or `Series` with `format='table'` or `append=True` is a no-op: the store is not modified and a `UserWarning` is emitted. Use `format='fixed'` to store an empty object.

  Examples

      >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"])
      >>> store = pd.HDFStore("store.h5", "w")
      >>> store.put("data", df)