NumPy array index is-1 and none

Source: Internet
Author: User

NumPy arrays are easy to use: to slice, use Boolean arrays or Boolean expressions to find qualifying data, or you can use an array as an index to another array to find the specified data. But sometimes you will see that the array index is-1 and none. The use of the two is as follows:

1.-1 the last one on the specified dimension. For example, an array of shape (3,3) data,data[2,-1] equals data[2,2];data[-1] equivalent to data[2];data[1,1:-1] equals Data[1,1:2]

2.None does not refer to a dimension in an algebraic group, none is used to change the dimensions of an array. For example, the shape of data is (3,3), the shape of Data[:,none] is (3,1,3), and the Shape of data (:,: None) is (3,3,1). It is easy to see that none is adding one dimension at the specified location, and the number of this dimension is 1. This will not change the total number of data, only the data dimension changes.

NumPy array index is-1 and none

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.