i have function returns panel , dataframe. example,
def fo(pn,df) update on pn,df return pn, df
then need call fo function update pn4 , pn3 below,
pn4.loc[0], pn3.loc[0] = fo(pn,df)
where pn4 panel4 structure , pn3 panel. far know, pn4.loc[0] should panel , pn3.loc[0] should dataframe. recieved error message when run such code
notimplementederror: cannot set using indexer panel yet!
so how can address error? in advance.
for futher information, post codes below:
def update(x, uc, sc, a, u): # accelerated version, examined on 07/15 in a: uc_old = uc.copy() u in u: uc.loc[a,:,u] = uc_old.loc[a,:,u] - uc_old.loc[a,:,x] * uc_old.loc[a,x,u] sc_old = sc.copy() sc.loc[:,a] = sc_old.loc[:,a] + uc_old.loc[a,x,:] * (1 - sc_old.loc[x,a]) return uc, sc def streaming(uc, au, k, u, a): ep = 0.01 sc = pd.dataframe(0.0, index = u, columns = a) max_mg = 0 x in u: mg = computemg(x, uc, sc, au, a, u) max_mg = mg if mg > max_mg else max_mg del sc c = [] s = {} m = max_mg while (m <= k*max_mg): c.append(m) s[m] = [] m = m * (1+ep) print len(c) ucc = pd.panel4d(dict([(c, uc.copy()) c in c])) scc = pd.panel(0., items = c, major_axis = u, minor_axis = a) x in u: c in c: if (computemg(x, ucc.loc[c], scc.loc[c], au, a, u) > c/float(2*k)) , (len(s[c])<k): s[c].append(x) ucc.loc[c], scc.loc[c] = update(x, ucc.loc[c], scc.loc[c], a, u) # error happens max_val = 0 c in c: val = 0 u in u: tsu = 0 in a: tsu += scc.loc[c,u,a] tsu = tsu / float(au.loc[u]) val += tsu if val > max_val: s = s[c] max_val = val return s, max_val
for dataframes , series, can use loc
, iloc
(and at
, iat
also) , set. requires coding make happen. error seeing
notimplementederror: cannot set using indexer panel yet!
means hasn't gotten around make happen panels yet.
you should able make assignment
pn4[0], pn3[0] = fo(pn,df)
Comments
Post a Comment