In Python, the tile()
function is used to construct an array by repeating the input array the number of times as specified by the reps
.
numpy.tile(A, reps)
This function takes the following parameter values:
A
: The is the input array.reps
: This is the number of repetitions for the input array.This function returns aa tiled output array.
import numpy as np# creating an input arraya = np.array([1,2,3,4,5])# calling the tile() functionmy_array = np.tile(a, 2)# printing the tiled arrayprint(my_array)
numpy
module.a
, using the array()
function.tile()
function and pass a
and 2
as arguments, meaning we are creating a tiled array having two repetitions of the array, a
. The result is assigned to a variable, my_array
.my_array
.