标签:构造 axis before app UNC dataframe frame a* pre
def func(x1,before,after,a,b):#x1代表一整行数据,before=line0,a=t(11)
print(x1[before])
print(a)
print(b)
return a*b
i=list(range(0,10))
i1=list(range(10,20))
i2=list(range(20,30))
ser=pd.DataFrame([i,i1,i2]).T#构造dataframe
ser.columns=["line0","line1","line2"]#指定行的名字
t=11#apply的参数
r={"k":123}#apply的参数
ser["qe"]=ser.apply(func,axis=1, args = (‘line0‘,‘line2‘),**{‘a‘:t,‘b‘:‘1t‘})
print(ser)
标签:构造 axis before app UNC dataframe frame a* pre
原文地址:https://blog.51cto.com/14156081/2373312