我在熊猫中有一个小组:
a0
<class 'pandas.core.panel.Panel'>
Dimensions: 1 (items) x 10 (major_axis) x 7 (minor_axis)
Items axis: 0.0 to 0.0
Major_axis axis: 0.0 to 20.0
Minor_axis axis: Alpha to Cn tot
我用
保存了面板a0.to_pickle('qq.pkl')
要阅读它,我使用:
a0=pd.read_pickle('qq.pkl')
当我第一次阅读文件时,没有任何问题,但是第二次它给了我这个输出:
a0=pd.read_pickle('qq.pkl')
File "/home/pt/.local/lib/python2.7/site-packages/pandas/io/pickle.py", line 37, in read_pickle
return pkl.load(fh)
UnpicklingError: A load persistent id instruction was encountered,
but no persistent_load function was specified.
这是一个错误吗?或者我做错了什么? (我在CentOS上,python 2.7,pandas 0.12.0)
编辑:我如何创建面板:
data1[al][ma]={'delta_PsPinf':delta_PsPinf,'Cz ClarckY':Cz_CY,'Cz NACA':Cz_NA,'Cz CY+NA':np.array(Cz_CY)+np.array(Cz_NA),'Fx':Fx,'Fy':Fy,'Fz':Fz,'Fz_adim':Fz_adim, 'Cz_tot': np.array(Cz_CY)+np.array(Cz_NA)+np.array(Fz_adim),'Hi':Hi,'Hi/f':Hi/array(force) }
a0=pd.Panel(data1[0.0])
a0.major_axis=force
a0.major_axis.name='force'
a0.minor_axis.name='var'
a0.sort_index(axis=2,ascending=False)
a0.to_excel('qq.xlsx')
a0.to_pickle('qq.pkl')
后处理:
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
#plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.rc('font', size=14.0)
import matplotlib.cm as cm
def plottingg(a,var,h,strr):
h.hold(True)
ii=0
for i in a.items:
c = cm.jet(ii*int(255/len(a0.items)),1)
q=a[i].plot(y=var,style=strr,label=[var+' Mach '+str(i)],color=c)
ii=ii+1
plt.xlabel('force')
q.legend(loc=2)
h.hold(False)
h=plt.figure()
a0=pd.read_pickle('qq.pkl')
a2=pd.read_pickle('qqq.pkl')
plottingg(a0,'Cz_tot',h,'--o')
plottingg(a0,'Cz CY+NA',h,'-*')
plt.show(True)
这里是文件链接
https://www.dropbox.com/s/y3omedfmrrhpyx1/provaCz3profilns.pkl