Trusted answers to developer questions

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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")

Syntax for the numpy.concatenate() function

The `concatenate()`

function takes the following parameter values.

: These are the input arrays to be concatenated. This is a required parameter.**(a1, a2, ...)**

: This is the given axis along which the input arrays will be joined. This is an optional parameter.**axis**

: This is the destination path for the result. This is an optional parameter.**out**

: 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.**dtype**

: This controls the kind of datacasting that may occur. This is an optional parameter.**casting**

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)

Implementing the numpy.concatenate() function

- Line 1: We import the
`numpy`

module. - Lines 3–4: We create input arrays,
`a`

and`b`

, using the`np.array()`

function. - Line 7: We concatenate the input arrays using the
`np.concatenate()`

function. The result is assigned to a variable,`myarray`

. - Line 10: We print the concatenated array,
`myarray`

.

RELATED TAGS

function

python

numpy

communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Related Courses