feather helper是一个用于缓存numpy数组和pandas数据帧的简洁接口。
featherhelper的Python项目详细描述
羽毛辅助对象
feather helper是一个用于缓存和加载numpy数组和pandas数据帧的简洁接口。我和Pandoctools/Knitty一起使用。
内容
安装
通过Conda:
conda install -c defaults -c conda-forge featherhelper
通过PIP:
pip install featherhelper
用法示例
importpandasaspdimportnumpyasnpimportfeatherhelperasfhfh.setdir("~/feather/mydoc")# (optional)# fh.exc(1, 2) # force raise exceptions for names (optional)# %%fh.name(1)# can also be fh.name('id1'), default is 'default', 1 is the same as '1'try:# raise fh.Err # (optional)df,A,B=fh.pull()# control length can be set: fh.pull(N)exceptfh.Err:# calculate:print('push')df=pd.DataFrame(np.random.random(16).reshape(4,4))A=df.valuesB=np.random.random(16*3).reshape(4,2,2,3)#fh.push(df,A,B)print(df,'\n',A,'\n',B)
一个简短的例子:
importnumpyasnpimportfeatherhelperasfh# fh.exc()# %%try:A=fh.pull()exceptfh.Err:A=np.random.random(16).reshape(4,4)fh.push(A)