The concatenate() function in Python is used to concatenate or join a sequence of input arrays along an existing axis.
numpy.concatenate((a1, a2, ...), axis=0, out=None, dtype=None, casting="same_kind")
The concatenate() function takes the following parameter values.
(a1, a2, ...): These are the input arrays to be concatenated. This is a required parameter.axis: This is the given axis along which the input arrays will be joined. This is an optional parameter.out: This is the destination path for the result. This is an optional parameter.dtype: This is the data type of the desired output array. The value can be inferred from the data type of the input arrays. This is an optional parameter.casting: This controls the kind of datacasting that may occur. This is an optional parameter.The concatenate() function returns the concatenated array.
import numpy as np# creating input arraysa = np.array([[1, 2, 3], [4, 5, 6]])b = np.array([[7, 8, 9]])# concatenating the arraysmyarray = np.concatenate((a,b), axis=0)# printing the concatenated arrayprint(myarray)
numpy module.a and b, using the np.array() function.np.concatenate() function. The result is assigned to a variable, myarray.myarray.