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=True, dropna=False)[源代码]#

Store object in HDFStore.

Parameters:
keystr
value{Series, DataFrame}
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.

indexbool, default True

将 DataFrame 索引作为一列写入。

appendbool,默认 False

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

data_columnslist of columns or True, default None

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

encodingstr,默认 None

提供字符串的编码。

track_timesbool, default True

参数会传递给 ‘PyTables’ 的 ‘create_table’ 方法。如果设置为 False,则在创建时间无关的情况下,可以拥有相同的 h5 文件(相同的哈希值)。

dropnabool,默认 False,可选

删除缺失值。

Examples

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