NumPy

NumPy

NumPy is the fundamental package for scientific computing with Python.

What is NumPy?

NumPy is the basic package for scientific computing using Python. Among other things, it includes:

  • A powerful N-dimensional array of objects.
  • Precision broadcast function.
  • A tool that integrates C/C+ and Fortran code.
  • Powerful linear algebra, Fourier transform and random number functions.

Ndarray?

One of the most important features of NumPy is its N-dimensional array object, ndarray, which is a collection of data of the same type, starting with an index of the elements in the collection with a 0 subscript. A ndarray object is a multidimensional array used to hold elements of the same type. Each element in ndarray has an area of the same storage size in memory.

Slice and index

The contents of a ndarray object can be accessed and modified by indexing or slicing, just like the slicing of a list in Python. Ndarray arrays can be indexed based on 0 - n subscripts. Slice objects can be cut from the original array by using the built-in slice function and setting the start, stop and step parameters.

As Easy as 1, 2, 3

# 1. installation package
$ pip install numpy

# 2. enter python's interactive interface
$ python -i

# 3. Use Numpy
>>> from numpy import *
>>> eye(4)

# 4. Output result
array([[1., 0., 0., 0.],
       [0., 1., 0., 0.],
       [0., 0., 1., 0.],
       [0., 0., 0., 1.]])

Contact information

  • 📮Email: l@numpy.org.cn
  • 📩WeChat: iamnotahacker(If you want to join our group)

NOTE

Change the world from Python.

This site is recommended to use Python 3.xopen in new window and above.

Brothers