Data analysis using Python (v) NumPy Basics: Ndarray indexes and slices

Source: Internet
Author: User
Tags scalar python list

Conceptual Understanding
IndexThe value in the array is obtained by an unsigned integer value. slicesThat is, the description of a fragment in an array.
One-dimensional arrays
Index of a one-dimensional arrayThe index of a one-dimensional array and the Python list function like this:
slicing a one-dimensional arrayThe slice syntax format for a one-dimensional array is array[index1:index2], which means an array that starts at the INDEX1 index position to the end of the INDEX2 index (not including the index2) position. For example:
When you assign a value to a slice, the value acts on every element in the array fragment, for example:
Two-dimensional arrays
Index of a two-dimensional arrayWhen accessing a two-dimensional array with an indexed one-dimensional array, the obtained element is not a scalar but a one-dimensional array. For example:
Since the index of the two-dimensional array is returned as a one-dimensional array, one of the scalars can be accessed in the form of a one-dimensional array, for example:
slicing a two-dimensional arraySince the index of a two-dimensional array corresponds to a one-dimensional array, the slice of a two-dimensional array is a fragment of one-dimensional array:
multidimensional Arrays
index of multidimensional arraysIn a one-dimensional array, a single index value returns the corresponding scalar, and in a two-dimensional array, a single index value returns the corresponding one-dimensional array; In a multidimensional array, a single index value returns an array of a lower latitude, for example:
Boolean index
A Boolean index refers to an array of Boolean values that can be indexed as an array, and the returned data is a value corresponding to the location of the true value, for example:
Fancy Index
A fancy index refers to an array of integers for indexing. For example:
The next essay is: Data analysis using Python (vi) NumPy base: Ndarray vector operations, interested friends Welcome to pay attention to this blog, but also welcome you to add comments to discuss.

Data analysis using Python (v) NumPy Basics: Ndarray indexes and slices

Related Article

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.