np.array转换为list
1 meitan = shuju.iloc[start:end, 1:2]
zhengqi = shuju.iloc[start:end,2:3]
print(type(list(l)))
newmeitan = np.array(meitan) #[[][][]]
newzhengqi = np.array(zhengqi)#[[][][]]
print("转换前",newzhengqi)
newmeitan = newmeitan.reshape(1, len(newmeitan)).tolist() # [[2,1,1]]
newzhengqi = newzhengqi.reshape(1, len(newzhengqi)).tolist() # [[2,1,1]]
print("转换后",newzhengqi)
显示如下,第一个是转换前,第二个转化后
1 转换前 [[ 63.13064957]
[ 66.2085495 ]
[ 67.42173767]
[ 66.29841614]
[ 67.2869339 ]
[ 65.04029846]
[ 67.9384613 ]
[ 69.80317688]
[ 66.47814941]]
转换后 [[63.1306495666504, 66.2085494995117, 67.4217376708984, 66.2984161376953, 67.2869338989258, 65.0402984619141, 67.9384613037109, 69.8031768798828, 66.4781494140625]]
嵌套的python list转成一个一维的python list
1 x = [[2],[23],[3]]
y = sum(x,[])
print(y)