Python Tile function usage

Source: Internet
Author: User

The tile function is in the Python module numpy.lib.shape_base, and his function is to repeat an array. For example, Tile (a,n), the function is to repeat the array a n times to form a new array, we still use specific examples to illustrate the problem:

Let's start by introducing all the methods under NumPy:

>>> from numpy Import *

We create a, use tiles to create B, and look at the data structure of B:

>>> a=[0,1,2]
>>> B=tile (a,2)
>>> b
Array ([0, 1, 2, 0, 1, 2])

If we enter a tuple, we will get the same result, with the same b

>>> B=tile (A, ())
>>> b
Array ([[0, 1, 2, 0, 1, 2]])

Of course, we want a to become a two-dimensional array, it is necessary to change the way of repetition.

>>> B=tile (A, (2,1))
>>> b
Array ([[0, 1, 2],
[0, 1, 2]])

Python Tile function usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.