One - One Code All

Blog Content

pandas写入读取h5文件

Python 智能投研   2017-07-08 10:41:47

写入文件

使用函数:pd.HDFStore

import numpy as np
import pandas as pd
####生成9000,0000条数据,9千万条
a = np.random.standard_normal((90000000,4))
b = pd.DataFrame(a)
####普通格式存储:
h5 = pd.HDFStore('/data/stock/test_s.h5','w')
h5['data'] = b
h5.close()

####压缩格式存储
h5 = pd.HDFStore('/data/stock/test_c4.h5','w', complevel=4, complib='blosc')
h5['data'] = b
h5.close()

读取文件

使用函数:pd.read_hdf

参数:文件名,key

data=pd.read_hdf('/data/stock/test_c4.h5',key='data')



上一篇:【转载】智能投顾与智能投研:华尔街之狼来了
下一篇:量化科技2017年上半年营收70万元 业绩亏损325万元

The minute you think of giving up, think of the reason why you held on so long.