Data analysis using Python (6) NumPy Basics: Vector Computing

Source: Internet
Author: User

Vectorization refers to using an array expression instead of a loop to manipulate each element in the array.
The general functions provided by NumPy (both Ufunc functions) are functions that perform element-level operations on data in Ndarray. For example, the square function computes the square of each element, and the rint function rounds each element:
There are also some functions that accept 2 parameters, called two ufunc, such as the Add function and the maximum function:
numpy.where function
The Numpy.where function is a vectorized version of the ternary expression x if condition else y, for example:
The second and third parameters of the Np.where function are not necessary, and they can all be scalar values, for example:
Mathematical and statistical methods
For example, the Np.sum function can sum elements in an array:
For a two-dimensional array, the SUM function sums all the elements, but the two-dimensional array has two directions for the horizontal and vertical axes, so the sum function can also be summed in the direction of the two-dimensional array:

Data analysis using Python (6) NumPy Basics: Vector Computing

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.