"Python Data Analysis" NumPy module

Source: Internet
Author: User

NumPy modules can efficiently process data, provide array support, and many modules rely on him, such as: Pandas, SciPy, matplotlib

Installing NumPy

First to the website: https://www.lfd.uci.edu/~gohlke/pythonlibs/Find NUMPY+MKL

My Python version is 3.6.1, the system is 64-bit

So the package that corresponds to the download is:

After downloading the package, go to the directory where the package is located (for example: D:\ installation package \ installation package ~PYTHON\NUMPY-1.13.3+MKL-CP36-CP36M-WIN_AMD64.WHL).

Use the following command to install

Pip Install NUMPY-1.13.3+MKL-CP36-CP36M-WIN_AMD64.WHL

The first installation error is as follows:

The above error occurs because the environment variable is not configured

Solution:

Add a path to an environment variable

After the add is complete, re-execute

Pip Install NUMPY-1.13.3+MKL-CP36-CP36M-WIN_AMD64.WHL

After the installation is successful, then we can use NumPy.

NumPy Tutorials

(1) NumPy create a one-dimensional array

Syntax: Numpy.array ([element 1, Element 2,..., element n])

Import numpyx = Numpy.array (["1","2","5  ","one"])print(x)

Run Result: [' 1 ' 2 ' 5 ' 11 ']

(2) NumPy create a two-dimensional array

Syntax: Numpy.array ([[Element 1, Element 2,..., element n],[element 1, Element 2,..., element n],..., [element 1, Element 2,..., element N]])

Import= Numpy.array ([[11,4,2],[2,6,1],[32,6,42]])print(y)

Operation Result:

[[11 4 2]
[2 6 1]
[32 6 42]]

(3) Sort by using sort

ImportNumPy#Numpy.array ([element 1, Element 2,..., element n])x = Numpy.array (["m","2","5"," One"])#sort xX.sort ()Print(x)#Numpy.array ([[Element 1, Element 2,..., element n],[element 1, Element 2,..., element n],..., [element 1, Element 2,..., element N]])y = Numpy.array ([[11,4,2],[2,6,1],[32,6,42]])#Sort yY.sort ()Print(y)

Post-order results:

[' One ' 2 ' 5 ' m ']
[[2 4 11]
[1 2 6]
[6 32 42]]

Description: The following actions are based on the sorted array

(4) Get the values in the array

For example, get the 6 value of the array y

# gets the 6 value of the array y y1 = y[1][2]print(y1)

(5) Get maximum and minimum values

# gets the maximum value in Y and the minimum value y2 = y.max ()print(y2)# operation result is: 1=  Y.min ()print(y3)# operation result is:

(6) Slicing

Gets the value in the array according to the defined subscript value

Syntax: array [start subscript: End subscript +1]

 #   slice  x1 = X[1:3] #   print   (x1)  #   run result: [' 2 ' 5 ']  x2  = x[:2] #   Take the element from the beginning to the subscript 1  print   (x2)  #   run result: [' one ' 2 ']   x3  = x[1:] #   The element labeled 1 from the bottom has been taken to the last  print   (x3)  #   run result: [' 2 ' 5 ' m ']  

Python Data Analysis NumPy module

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.