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
(
self,
path_or_buf: FilePath | HDFStore,
*,
key: str,
mode: Literal["a", "w", "r+"] = "a",
complevel: int | None = None,
complib: Literal["zlib", "lzo", "bzip2", "blosc"] | None = None,
append: bool = False,
format: Literal["fixed", "table"] | None = None,
index: bool = True,
min_itemsize: int | dict[str, int] | None = None,
nan_rep=None,
dropna: bool | None = None,
data_columns: Literal[True] | list[str] | None = None,
errors: OpenFileErrors = "strict",
encoding: str = "UTF-8",
)
| 2639 | |
| 2640 | @final |
| 2641 | def to_hdf( |
| 2642 | self, |
| 2643 | path_or_buf: FilePath | HDFStore, |
| 2644 | *, |
| 2645 | key: str, |
| 2646 | mode: Literal["a", "w", "r+"] = "a", |
| 2647 | complevel: int | None = None, |
| 2648 | complib: Literal["zlib", "lzo", "bzip2", "blosc"] | None = None, |
| 2649 | append: bool = False, |
| 2650 | format: Literal["fixed", "table"] | None = None, |
| 2651 | index: bool = True, |
| 2652 | min_itemsize: int | dict[str, int] | None = None, |
| 2653 | nan_rep=None, |
| 2654 | dropna: bool | None = None, |
| 2655 | data_columns: Literal[True] | list[str] | None = None, |
| 2656 | errors: OpenFileErrors = "strict", |
| 2657 | encoding: str = "UTF-8", |
| 2658 | ) -> None: |
| 2659 | """ |
| 2660 | Write the contained data to an HDF5 file using HDFStore. |
| 2661 | |
| 2662 | Hierarchical Data Format (HDF) is self-describing, allowing an |
| 2663 | application to interpret the structure and contents of a file with |
| 2664 | no outside information. One HDF file can hold a mix of related objects |
| 2665 | which can be accessed as a group or as individual objects. |
| 2666 | |
| 2667 | In order to add another DataFrame or Series to an existing HDF file |
| 2668 | please use append mode and a different a key. |
| 2669 | |
| 2670 | .. warning:: |
| 2671 | |
| 2672 | One can store a subclass of ``DataFrame`` or ``Series`` to HDF5, |
| 2673 | but the type of the subclass is lost upon storing. |
| 2674 | |
| 2675 | For more information see the :ref:`user guide <io.hdf5>`. |
| 2676 | |
| 2677 | Parameters |
| 2678 | ---------- |
| 2679 | path_or_buf : str or pandas.HDFStore |
| 2680 | File path or HDFStore object. |
| 2681 | key : str |
| 2682 | Identifier for the group in the store. |
| 2683 | mode : {'a', 'w', 'r+'}, default 'a' |
| 2684 | Mode to open file: |
| 2685 | |
| 2686 | - 'w': write, a new file is created (an existing file with |
| 2687 | the same name would be deleted). |
| 2688 | - 'a': append, an existing file is opened for reading and |
| 2689 | writing, and if the file does not exist it is created. |
| 2690 | - 'r+': similar to 'a', but the file must already exist. |
| 2691 | complevel : {0-9}, default None |
| 2692 | Specifies a compression level for data. |
| 2693 | A value of 0 or None disables compression. |
| 2694 | complib : {'zlib', 'lzo', 'bzip2', 'blosc'}, default 'zlib' |
| 2695 | Specifies the compression library to be used. |
| 2696 | These additional compressors for Blosc are supported |
| 2697 | (default if no compressor specified: 'blosc:blosclz'): |
| 2698 | {'blosc:blosclz', 'blosc:lz4', 'blosc:lz4hc', 'blosc:snappy', |
no outgoing calls