Repeat and Tile
repeat repeats each element and tile repeats the whole array.
Example
import numpy as np
a = np.array([1, 2])
print(np.repeat(a, 3))
print(np.tile(a, 3))
print(np.tile(a, (2, 2)))Result
[1 1 1 2 2 2] [1 2 1 2 1 2] [[1 2 1 2] [1 2 1 2]]
Exercise
Repeat the whole array.
np.(a, 3)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.