numpy.repeat() in Python

The numpy.repeat() function repeats the elements of an array.

Syntax

Parameter

The numpy.repeat() function consists of three parameters, which are as follows:

a: This parameter represents the input array.

repeats: This parameter represents the number of repetitions for each element. 

axis: It signifies the axis along which to repeat the values. By default, it uses the flattened input array, and returns a flat output array.

Return

This function returns the output array (ndarray) which has the same shape as parameter ‘a’, except along the given axis.

Example 1

Output

 

Pin It on Pinterest

Share This