np.array转换为list 1 meitan = shuju.iloc[start:end, 1:2
]
2
3 zhengqi = shuju.iloc[start:end,2:3
]
4 print(type(list(l)))
5 newmeitan = np.array(meitan)
#[[][][]]
6 newzhengqi = np.array(zhengqi)
#[[][][]]
7 print(
"转换前",newzhengqi)
8 newmeitan =
newmeitan.reshape(1, len(newmeitan)).tolist() # [[2,1,1]]
9
10 newzhengqi =
newzhengqi.reshape(1, len(newzhengqi)).tolist() # [[2,1,1]]
print("转换后",newzhengqi)
显示如下,第一个是转换前,第二个转化后 1 转换前 [[ 63.13064957
]
2 [ 66.2085495
]
3 [ 67.42173767
]
4 [ 66.29841614
]
5 [ 67.2869339
]
6 [ 65.04029846
]
7 [ 67.9384613
]
8 [ 69.80317688
]
9 [ 66.47814941
]]
10 转换后 [[63.1306495666504, 66.2085494995117, 67.4217376708984, 66.2984161376953, 67.2869338989258, 65.0402984619141, 67.9384613037109, 69.8031768798828, 66.4781494140625]]
嵌套的python list转成一个一维的python list1 x = [[2],[23],[3
]]
2 y =
sum(x,[])
3 print(y)
显示如下1 [2, 23, 3]
转载于:https://www.cnblogs.com/shizhenqiang/p/8192893.html
相关资源:JAVA上百实例源码以及开源项目