Pandas DataFrame: to_hdf() function
DataFrame - to_hdf() function
The to_hdf() function is used to write the contained data to an HDF5 file using HDFStore.
Syntax:
DataFrame.to_hdf(self, path_or_buf, key, **kwargs)
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
path_or_buf | File path or HDFStore object. | str or pandas.HDFStore | Required |
key | Identifier for the group in the store. | str | Required |
mode | Mode to open file:
|
{'a', 'w', 'r+'} Default Value: ‘a’ |
Required |
format | Possible values:
|
{‘fixed’, ‘table’} Default Value: ‘fixed’ |
Required |
append | For Table formats, append the input data to the existing. | bool Default Value: False |
Required |
data_columns | 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. | list of columns Default Value: True |
Optional |
complevel | Specifies a compression level for data. A value of 0 disables compression. | {0-9} | Optional |
complib | Specifies the compression library to be used. As of v0.20.2 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. | {‘zlib’, ‘lzo’, ‘bzip2’, ‘blosc’} Default Value: ‘zlib’ |
Required |
fletcher32 | If applying compression use the fletcher32 checksum. | bool Default Value: False |
Required |
dropna | If true, ALL nan rows will not be written to store. | bool Default Value: False |
Required |
errors | Specifies how encoding and decoding errors are to be handled. See the errors argument for open() for a full list of options. | str Default Value: ‘strict’ |
Optional |
Example:
Download the Pandas DataFrame Notebooks from here.
Previous: DataFrame - to_csv() function
Next: DataFrame - to_sql() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/pandas/dataframe/dataframe-to_hdf.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics