我有兩個不同的數組,我想要相互結合,以便新的數組仍舊與每個舊數組相同。如何在Python中壓縮兩個數組並保持原始形狀?
import numpy as np
x = (['1','2','3','4','5','6','7','8','9'])
y = (['a','b','c','d','e','f','g','h','i'])
z = np.array(zip(x,y))
print z
print np.shape(z)
讓我
[['1' 'a']
['2' 'b']
['3' 'c']
['4' 'd']
['5' 'e']
['6' 'f']
['7' 'g']
['8' 'h']
['9' 'i']]
(9, 2)
,我想有
[['1 a']
['2 b']
['3 c']
['4 d']
['5 e']
['6 f']
['7 g']
['8 h']
['9 i']]
(9,)
,因爲我需要新的陣列只有一個用於進一步加工尺寸。 因爲我是一個新手,我認爲zip()函數可能不是正確的,但我也試過.join()函數,我無法弄清楚這種方式。
呃......什麼是np? – Muctadir