Posts

Showing posts with the label np.hstack

Array Concatenation and methods of stack | numpy array tutorial | Codin india

Image
    Numpy is Python module that is used for array creation, modification and creating sub arrays for numpy arrays. Concatenation of arrays Concatenation or joining of two arrays in Numpy, is primarily accomplished through the routines np.concatenate, np.vstack and np.hstack. Let us see all of the one by one. Concatenate:- It will concatenate two arrays and gives the output as one array. Let us see by code:- From the above code, it is clear that np.concatenate takes two argument as input and adds the value of both array and return the output as one array. Concatenate 3 or more arrays:- we can concatenate as any array we want. Let us talk, where the case of 3 arrays, we will concatenate all the 3 arrays Concatenation of same array:- We can also concatenate same array together. Like we can concatenate x + x. Let's see the Code:- NOTE:-   point here to be noted that, the arguments should be passed in [] brackets only.  np.concatenate([x, y]) 2-D or multidimensional Array Concatenation: