Lego Ai_python (b): NumPy index, slice, common function

Source: Internet
Author: User

indexes and slices for numpy

The contents of the Ndarray object can be viewed and modified through indexing and tiling.

Index: An element index in an Ndarray object based on 0

Slice: A description of a region of a fragment in an array

The slices of an array can also be understood as a partial view of the original array, all pointing to the original array in memory, so the changes on the slices are reflected directly on the original array, unlike the list copy .

Example code for an indexed tile demonstrates:

NumPy Code demos for common functions:

NumPy substitution function transpose, T, and swapaxes presentation and distinction

T applies to one or two-D arrays

arr = Np.arange (a). Reshape (3,4) #生成一个3行4列的数组
Print (arr) print (arr. T

Transpose is understood to be the operation of the data shape property and the conversion, the instance code is as follows

Swapaxes received parameters are a pair of axis numbers for axis swap operations

NumPy Matrix arithmetic function This one's not going to be a demo. Interested to know

(Additional numpy will be appended to the next step as an extension article)

Filed under: Lego Ai_python (i):Pandas basic Knowledge

Lego Ai_python (b): NumPy index, slice, common function

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.