pandas.HDFStore.append#

HDFStore.append(key, value, format=None, axes=None, index=True, append=True, complib=None, complevel=None, columns=None, min_itemsize=None, nan_rep=None, chunksize=None, expectedrows=None, dropna=<no_default>, data_columns=None, encoding=None, errors='strict')[source]#

Append to Table in file.

Node must already exist and be Table format.

Parameters:
keystr

Key of object to append.

value{Series, DataFrame}

Value of object to append.

format‘table’ is the default

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

'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.

axeslist, default None

Single-element list selecting the axis to store as the table’s indexed (appendable) axis: [0] for the index (the default) or [1] for the columns. Ignored when appending to an existing table, which keeps the axes it was created with.

indexbool, default True

Write DataFrame index as a column.

appendbool, default True

Append the input data to the existing.

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

Compression library to use; None disables compression. See the complib parameter of HDFStore for the full list of supported compressors.

complevelint, 0-9, default None

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

columnsdefault None

This parameter is currently not accepted, try data_columns.

min_itemsizeint, 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_repstr, default ‘nan’

Str to use as str nan representation.

chunksizeint, default 100000

Number of rows to write in each chunk.

expectedrowsint

Expected TOTAL row size of this table.

dropnabool, default False, optional

Do not write an ALL nan row to the store settable by the option ‘io.hdf.dropna_table’.

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.

data_columnslist of columns, or True, default None

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 here.

encodingdefault None

Provide an encoding for str.

errorsstr, 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.

See also

HDFStore.append_to_multiple

Append to multiple tables.

Notes

Does not check if data being appended overlaps with existing data in the table, so be careful

Appending an empty DataFrame or Series is a no-op: the store is not modified and a UserWarning is emitted.

Examples

>>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"])
>>> store = pd.HDFStore("store.h5", "w")
>>> store.put("data", df1, format="table")
>>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=["A", "B"])
>>> store.append("data", df2)
>>> store.close()
   A  B
0  1  2
1  3  4
0  5  6
1  7  8