array数组(n,1)和(n,)互相转换

data.shape
#(172,1)
result = [arr[0] for arr in data]
result.shape
#(172,)
(172,1)表示是一个(172,1)shape大小的数据,而(172,)表示只知道有172行数据
使用方法reshape()即可转换
new_data = result.reshape(-1,1) #-1默认是任何数量的数集,转化为(n,1)
#(172,1)
data1 = new_data.reshape(-1,) #转换为(n,)
#(172,)

 

posted @ 2019-04-23 09:50  落地成霜  阅读(411)  评论(0编辑  收藏  举报