What Is the Tile Function in NumPy?

Learn via video course
FREE
View all courses
Python Course for Beginners With Certification: Mastering the Essentials
Python Course for Beginners With Certification: Mastering the Essentials
by Rahul Janghu
1000
4.90
Start Learning
Python Course for Beginners With Certification: Mastering the Essentials
Python Course for Beginners With Certification: Mastering the Essentials
by Rahul Janghu
1000
4.90
Start Learning
Topics Covered

A tile is a thin rectangular slab made of concrete, which is used to cover roofs, floors, etc. When we congregate two or more tiles in the same way, we get a tile floor.

The tile function in NumPy is a function that repeats the input array an arbitrary number of times. The resulting array has the same dimensions as the input array.

Build an AI-First Career, Master the Complete Skillset

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program
NSDC Certified

AI Forward Deployed Engineer Program

Full-stack engineering, production AI and client-facing consulting

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program

Syntax of NumPy Tile

The syntax for the tile function in NumPy is:

Parameters

The parameters for the np tile function in NumPy are:

  • arr: Input array.
  • repetitions: The number of repetitions we want for our array.
Sharpen Your Fundamentals with Free Learning

Examples of NumPy Tile Function

After understanding the syntax and various parameters of the np tile function in NumPy, let's dive into some examples to make our concepts better:

  • Basic Example

    Output

    As we can see, our input array ([0, 1, 2, 3]) has been repeated twice after using the tile() function.

  • NumPy Tile Vertically

    Just as we horizontally repeat an array, we can repeat an array vertically too!

    Output

    With the help of changing the repetitions, we can repeat an array vertically. We have added coordinates to the repetitions variable because we need to make the column of the matrix 1. There are no such limits on rows.

  • Tiling Input Array Both Vertically And Horizontally

    In this section, we will see a method to tile a one-dimensional array to a matrix. To achieve this, we need to make some minor changes to the code for vertical tiling.

    Output

    Hence, we have obtained a two-dimensional matrix from a one-dimensional array using horizontal and vertical tiling.

  • Numpy Tile Example in 2-D Array

    In this example, we will convert a one-dimensional array into its tile equivalent in a two-dimensional array. We will try to create a square matrix (A matrix having equal rows and columns is termed a square matrix).

    Output

    Hence, we converted our one-dimensional array ([2, 4, 6, 8]) into its tile equivalent in a square matrix.

How Scaler Transformed Careers in Different Fields

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Applications of NumPy Tile Function

Like other NumPy array manipulation functions, the np Tile() function has advantages that we can use to ease our life as developers.

The np Tile() function in NumPy can be used to replicate an array n times and in n dimensions. This gives us complete control over our arrays, which results in more efficiency while coding.

Testing is a very important step in a software lifecycle, and many times we get stuck when we create new test data for our prototype. With the help of the tile function, we can generate seemingly related arrays but have repetitions in them.

The np Tile() in NumPy is one of the most frequently used functions in calculations of Mathematics and Applied Sciences. To create variations, eigenvalues and eigenvectors include the use of the tile() function in Python.

Conclusion

  • The np Tile() function in NumPy helps us to create an array by simply replicating the number of repetitions by a variable.
  • We understood the syntax and parameters of the np tile() function, along with the various changes we made to get our desired replicated array.
  • Apart from this, we also saw a few types of replicated arrays; Vertical tiling, vertical and horizontal tiling, and tiling in a two-dimensional matrix.