欲從2D numpy
陣列這樣將字符串,連接字符串
for x in np.ndindex(mat.shape[0]):
concat = ""
for y in range(len(columns)):
concat += str(mat[x][2 + y])
其中mat
是含有string
S或int
S IN的每個小區的2D陣列,columns
是一個mat
的列名列表,例如['A', 'B', 'C', 'D']
,使用mat[x][2 + y]
來避免連接來自前兩列的字符串。我想知道做什麼最好的方法,可能是以更簡潔/有效的方式。