for i in range(12,16):
temp[:,i-12] = data.iloc[:,i]-data.iloc[:,i-1]/data.iloc[:,i-1]
#x['主营业务增长率'] = np.mean(temp,axis=1)
TypeError: unsupported operand type(s) for -: 'str' and 'float'
1.怎么修正?
2.temp[],内置在for i in range(12,16)怎么理解?
你列表里的值都是字符串类型的,不能和浮点数相减,需要将你的字符串转化为整数或者浮点数,才可以和浮点数相减。
temp[]放在for里面就是实时地储存数据了
望采纳!谢谢