Let us explore how this routine works and how we can use it.
The syntax of the numpy c_ routine is as shown below:
The routine does not take any parameters except the arrays that you need to concatenate.
It will then return the concatenated array along the second axis.
The example below illustrates how to use the np.c_ to concatenate two arrays.
In this example, the np.c_ routine takes the arrays and concatenates them along the second axis.
NOTE: When talking about the second axis, we refer to the axis=1 or the column axis.
The code above should return an array as:
In this case, the np.c_ takes two one-dimensional arrays and concatenates them to form a two-dimensional array.
Let us see what happens when we apply the routine in 2d arrays.
The code snippet above should return:
This article aims to help you understand NumPy’s indexing routine np.c_ and how to use it.
Thanks for reading!!!