[Reading notes] Python Data Analysis (12) Advanced NumPy

Source: Internet
Author: User

Da

Array: A fast and flexible homogeneous multidimensional data set container that can be used to perform some mathematical operations on the entire block of data

    • Data pointers, part of system memory
    • DataType Data Type/dtype
    • Tuple that indicates the size of the data
    • Stride:strides holds the number of bytes added to the pointer in the data store when the subscript for each axis increases by 1 o'clock
      • In [6]: Np.ones ((3,4,5), Dtype=np.float64). Strides

OUT[6]: (160, 40, 8)

Ndarray Data structure:

Reshape () function-1 parameter, the content of the dimension is automatically populated by the original content

C Vesu Fortran Order:

    • : Row Order
    • Fortran Order:column Order

The Ndarray of NumPy is the row order, and the reshape () and Ravel () functions accept a parameter for c/f conversion

Array refactoring

More Concise array refactoring: C_, R_c

Array Duplication/replication

Repeat: Repeats each element in an array for a specific number of times, and you can specify the number of repetitions for each element

Tile: Repeat recovery on the specified axis

Take and Put

Remove a specific element from an array

broadcasting/Broadcast

Spreads along the x-axis and spreads along the y-axis with subtle differences

Np.newaxis () Add new axis

Advanced Ufunc Usage

Ufunc is the abbreviation for universal function, which is a function that can operate on each element of an array, numpy many of the Ufunc functions are implemented at the C level, so they are computationally fast

    • Np.add.reduce: Add and operate
    • Np.add.accumulate: Similar to reduce, returns the same shape as the input array, saving all intermediate calculation results

    • Np.multiply.outer:element-wise dot Product

user-defined functions

Frompyfunc

Structured and Record Arrays


Use Dtype to create structured tabular data, similar to the structure in C

NumPy sort

Argsort:

Lexsort: multiple sort

searchsorted

    • Finds the elements in the sorted array, returns the position where the lookup value should be inserted in the array, which can make the array still orderly
    • can also be used to find the position of an element within a certain interval

Speed performance:

Cpython

[Reading notes] Python Data Analysis (12) Advanced NumPy

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.