在不存储索引的情况下将Pandas DataFrame存储在PyTables表中 [英] Store pandas DataFrame in PyTables table without storing index

查看:152
本文介绍了在不存储索引的情况下将Pandas DataFrame存储在PyTables表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在许多DataFrame.to_foo函数中,我可以指定不想写索引

In many DataFrame.to_foo functions I can specify that I don't want to write the index

>>> help(df.to_csv)

Write DataFrame to a comma-separated values (csv) file

Parameters
----------
...
index : boolean, default True
    Write row names (index)
...

DataFrame.to_hdf是否存在类似的功能?我不想将索引存储在PyTables表中.

Does similar functionality exist for DataFrame.to_hdf? I would like to not store the index in the PyTables table.

推荐答案

您可以调出h5py并直接与HDF5交互.

You could call out to h5py and interact with HDF5 directly.

data = df.values
with h5py.File('data.h5','w') as f:
    f.create_dataset('my_table', data=data)

这篇关于在不存储索引的情况下将Pandas DataFrame存储在PyTables表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆