y.html)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ DataFrame ](../frame.html)
  * pandas.DataF... 

#  pandas.DataFrame.to_hdf  #

DataFrame.  to_hdf  (  _ path_or_buf  _ , _ *  _ , _ key  _ , _ mode  =  'a'
_ , _ complevel  =  None  _ , _ complib  =  None  _ , _ append  =  False  _ ,
_ format  =  None  _ , _ index  =  True  _ , _ min_itemsize  =  None  _ , _
nan_rep  =  None  _ , _ dropna  =  None  _ , _ data_columns  =  None  _ , _
errors  =  'strict'  _ , _ encoding  =  'UTF-8'  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L2719-L2871) #

    

Write the contained data to an HDF5 file using HDFStore.

Hierarchical Data Format (HDF) is self-describing, allowing an application to
interpret the structure and contents of a file with no outside information.
One HDF file can hold a mix of related objects which can be accessed as a
group or as individual objects.

In order to add another DataFrame or Series to an existing HDF file please use
append mode and a different a key.

Warning

One can store a subclass of ` DataFrame  ` or ` Series  ` to HDF5, but the
type of the subclass is lost upon storing.

For more information see the [ user guide  ](../../user_guide/io.html#io-hdf5)
.

Parameters  :

    

**path_or_buf** str or pandas.HDFStore

    

File path or HDFStore object.

**key** str

    

Identifier for the group in the store.

**mode** {âaâ, âwâ, âr+â}, default âaâ

    

Mode to open file:

  * âwâ: write, a new file is created (an existing file with the same name would be deleted). 

  * âaâ: append, an existing file is opened for reading and writing, and if the file does not exist it is created. 

  * âr+â: similar to âaâ, but the file must already exist. 

**complevel** {0-9}, default None

    

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

**complib** {âzlibâ, âlzoâ, âbzip2â, âbloscâ}, default
âzlibâ

    

Specifies the compression library to be used. These additional compressors for
Blosc are supported (default if no compressor specified: âblosc:blosclzâ):
{âblosc:blosclzâ, âblosc:lz4â, âblosc:lz4hcâ, âblosc:snappyâ,
âblosc:zlibâ, âblosc:zstdâ}. Specifying a compression library which is
not available issues a ValueError.

**append** bool, default False

    

For Table formats, append the input data to the existing.

**format** {âfixedâ, âtableâ, None}, default âfixedâ

    

Possible values:

  * â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. 

  * If None, pd.get_option(âio.hdf.default_formatâ) is checked, followed by fallback to âfixedâ. 

**index** bool, default True

    

Write DataFrame index as a column.

**min_itemsize** dict or int, optional

    

Map column names to minimum string sizes for columns.

**nan_rep** Any, optional

    

How to represent null values as str. Not allowed with append=True.

**dropna** bool, default False, optional

    

Remove missing values.

**data_columns** list of columns or True, optional

    

List of columns to create as indexed data columns for on-disk queries, or True
to use all columns. By default only the axes of the object are indexed. See [
Query via data columns  ](../../user_guide/io.html#io-hdf5-query-data-columns)
. for more information. Applicable only to format=âtableâ.

**errors** str, default âstrictâ

    

Specifies how encoding and decoding errors are to be handled