我有一个1xn数组,如下所示:
data = [-2 -1 -3 -5 2 5 8 9 ..... 8]现在,我想将它与其他类似的1xn数组连接起来:
data2 = [0 3 0 0 ..... 5]final是一个有很多行的大矩阵
[data]
[data2]
...
[data1000]它的Python代码是什么?
发布于 2017-05-16 12:41:09
data = [1,2,3,4]
data2 = [1,2,3]
#put the list of lists to a DataFrame which will make the equal length and fill missing elements with NA. Then use values to get the M*N numpy array.
pd.DataFrame([data,data2]).values
Out[371]: 
array([[  1.,   2.,   3.,   4.],
       [  1.,   2.,   3.,  nan]])https://stackoverflow.com/questions/43991786
复制相似问题