# numpy.tile () in Python

Parameters :

`  array:  [array_like] Input array.  repetitions:  No. of repetitions of arr along each axis. `

Return:

` An array with repetitions of array - arr as per d, number of times we want to repeat arr `

Code 1:

 ` # Python program illustrating ` ` # numpy.tile () `   ` import ` ` numpy as geek `   ` # Working on 1D ` ` arr ` ` = ` ` geek.arange (` ` 5 ` `) ` ` print ` ` (` ` "arr:" ` `, arr) `   ` repetitions ` ` = ` ` 2 ` ` print ` ` (` ` "Repeating arr 2 times:" ` `, geek.tile (arr , repetitions)) `   ` repetitions ` ` = ` ` 3 ` ` print ` ` (` `" Repeating arr 3 times: "` `, geek.tile (arr, repetitions)) ` ` # [0 1 2 ..., 2 3 4] means [0 1 2 3 4 0 1 2 3 4 0 1 2 3 4] ` ` # since this was long output, so it uses [...] `

Output:

` arr: [0 1 2 3 4] Repeating arr 2 times: [0 1 2 3 4 0 1 2 3 4] Repeating arr 3 times: [0 1 2 ..., 2 3 4] `

Code 2:

 ` # Python program illustrating ` ` # numpy .tile () `   ` import ` ` numpy as geek `   ` arr ` ` = ` ` geek.arange (` ` 3 ` `) ` ` print ` ` (` `" arr: "` `, arr) ` ` `  ` a ` ` = ` ` 2 `  ` b ` ` = ` ` 2 `  ` repetitio ns ` ` = ` ` (a, b) ` ` print ` ` (` ` "Repeating arr:" ` `, geek.tile (arr, repetitions)) ` ` print ` ` (` ` "arr Shape: "` `, geek.tile (arr, repetitions) .shape) ` ` `  ` a ` ` = ` ` 3 `  ` b ` ` = ` ` 2 `  ` repetitions ` ` = ` ` (a, b) ` ` print ` ` (` ` "Repeating arr:" ` `, geek.tile (arr, repetitions)) ` ` print ` ` (` ` "arr Shape:" ` `, geek.tile (arr, repetitions) .shape) `   ` a ` ` = ` ` 2 ` ` b ` ` = ` ` 3 `  ` repetitions ` ` = ` ` (a, b) ` ` print ` ` (` ` "Repeating arr:" ` `, geek.tile (arr, repetitions)) ` ` print ` ` (` ` "arr Shape:" ` `, geek.tile (arr , repetitions) .shape) `

Output:

` arr: [0 1 2] Repeating arr: [[0 1 2 0 1 2] [0 1 2 0 1 2]] arr Shape: (2, 6) Repeating ar r: [[0 1 2 0 1 2] [0 1 2 0 1 2] [0 1 2 0 1 2]] arr Shape: (3, 6) Repeating arr: [[0 1 2 ..., 0 1 2] [0 1 2 ..., 0 1 2]] arr Shape: (2, 9) `

Code 3: (repetitions == arr.ndim) == 0

 ` # Python program illustrating ` ` # numpy.tile () `   ` import ` ` numpy as geek `   ` arr ` ` = ` ` geek.arange (` ` 4 ` `). reshape (` ` 2 ` `, ` ` 2 ` ` ) ` ` print ` ` (` ` "arr:" ` , arr)   ` a ` ` = ` ` 2 `  ` b ` ` = ` ` 1 `  ` repetitions ` ` = ` ` (a, b) ` ` print ` ` (` ` "Repeating arr:" ` `, geek.tile (arr, repetitions)) ` ` print ` ` (` ` "arr Shape:" ` `, geek.tile (arr, repetitions) .shape) `   ` a ` ` = ` ` 3 `  ` b ` ` = ` ` 2 `  ` re petitions ` ` = ` ` (a, b) ` ` print ` ` (` ` "Repeating arr:" ` `, geek.tile (arr, repetitions)) ` ` print ` ` (` ` "arr Shape: "` `, geek.tile (arr, repetitions) .shape) ` ` `  ` a ` ` = ` ` 2 ` ` b ` ` = ` ` 3 `  ` repetitions ` ` = ` ` (a, b) ` ` print ` ` (` ` "Repeating arr:" ` `, geek.tile (arr, repetitions)) ` ` print ` < code class = "plain"> ( ` "arr Shape:" ` `, geek.tile (arr, repetitions) .shape) `

Output:

` arr: [[0 1] [2 3]] Repeating arr: [[0 1] [2 3] [0 1] [2 3]] arr Shape: (4, 2) Repeating arr: [[0 1 0 1] [2 3 2 3] [0 1 0 1] [2 3 2 3] [0 1 0 1] [2 3 2 3]] arr Shape: (6, 4) Repeating arr: [[0 1 0 1 0 1] [2 3 2 3 2 3] [0 1 0 1 0 1] [2 3 2 3 2 3]] arr Shape: (4, 6) `

numpy.tile.html> https://docs.scipy.org/doc/numpy/ reference / generated / numpy.tile.html

Notes:
These codes will not work for online IDs. Please run them on your systems to see how they work

## Shop Learn programming in R: courses

\$FREE Best Python online courses for 2022

\$FREE Best laptop for Fortnite

\$399+ Best laptop for Excel

\$ Best laptop for Solidworks

\$399+ Best laptop for Roblox

\$399+ Best computer for crypto mining

\$499+ Best laptop for Sims 4

\$

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

PythonStackOverflow

Check if one list is a subset of another in Python

PythonStackOverflow

How to specify multiple return types using type-hints

PythonStackOverflow

Printing words vertically in Python

PythonStackOverflow

Python Extract words from a given string

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

PythonStackOverflow

Python os.path.join () method

PythonStackOverflow

Flake8: Ignore specific warning for entire file

## Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries