Python: concatenate 3 arrays

I have its arrays and want to combine them

import numpy as np a = np.array([[1,2,3],[4,5,6]]) b = np.array([[7,8,9],[10,11,12]]) c = np.array([[13,14,15],[16,17,18]]) 

To obtain:

 array([1,2,3,7,8,9,13,14,15, 4,5,6,10,11,12,16,17,18]) 

What is the function for this?

Thanks:)

+6
source share
2 answers

Stack them horizontally np.hstack and flatten with np.ravel -

 np.hstack(( a,b,c )).ravel() 
+9
source
 d=np.concatenate((a, b,c), axis=None) 
0
source

Source: https://habr.com/ru/post/1264786/


All Articles