close

Python - Array 拼接+

>>> a=np.array([1,2,3])
>>> b=np.array([11,22,33])
>>> c=np.array([44,55,66])
>>>

np.concatenate((a,b,c),axis=0)              # 默认情况下,axis=0可以不写
array([ 1,  2,  3, 11, 22, 33, 44, 55, 66])  #对于一维数组拼接,axis的值不影响最后的结果

 

>>> a=np.array([[1,2,3],[4,5,6]])
>>> b=np.array([[11,21,31],[7,8,9]])
>>> np.concatenate((a,b),axis=0)
array([[ 1,  2,  3],
       [ 4,  5,  6],
       [11, 21, 31],
       [ 7,  8,  9]])

>>> np.concatenate((a,b),axis=1)  #axis=1表示对应行的数组进行拼接
array([[ 1,  2,  3, 11, 21, 31],
       [ 4,  5,  6,  7,  8,  9]])

 

======

>>> text = 'a,b,c' >>> text = text.split(',') >>> text [ 'a', 'b', 'c' ]
 

======

Array 刪除

 

參考

https://blog.csdn.net/zyl1042635242/article/details/43162031

https://stackoverflow.com/questions/5387208/how-to-convert-a-string-to-a-list-in-python

http://puremonkey2010.blogspot.com/2017/06/python-numpy-append-1d-array-to-2d.html

全站熱搜
創作者介紹
創作者 ricky10116r2d2 的頭像
ricky10116r2d2

ricky10116r2d2的部落格

ricky10116r2d2 發表在 痞客邦 留言(0) 人氣()