Get the App
SLTechnology News&Howtos  ›  Network Security  › 

How to get started with Numpy in python data Analysis

Shulou Source: shulou.com Published: 2022-05-31 23:19:34 09月26日 Update

This article shows you how to get started with Numpy in python data analysis. the content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

I. installation

First of all, you need to build the Python environment, and on this basis, open the cmd command line to enter

-pip install Numpy

After installing the Numpy library, we can proceed to the next step. 2. Simple application

Import library import numpy as np create object a=np.arange (5) View object type a.dtype view object element a view shape a.shape

Third, create a multidimensional array

M=np.array ([np.arange (2), np.arange (2)]) / / create an array containing two lists, with two elements in each list

Fourth, select Numpy array elements

/ / create a two-row and two-column array (similar to a two-dimensional array in java) a=np.array ([1rect 2], [3jue 4]) / / Select array elements a [0mem0] 1a [1mem0] 2a [1JEN 1] 4a [1JEO] 3

Remember: converting plural types to integers is not allowed. When you try to do this conversion, a TypeError error will be triggered. Ps: datatypes. I will sort them out for you this week.

5. Slice and index of one-dimensional array

/ / first create an array a = np.arange (9) aarray ([0, 1, 2, 3, 4, 5, 6, 7, 8]) slice a [4:6] output: array ([4,5]) ps: array slice has three parameters, initial position, end position interval.

Sixth, deal with the array shape

/ / one-dimensional to multi-dimensional > > b=np.arange (24). Reshape (2pyr3) > barray ([0,1,2be3], [4,5,6,7], [8,9,10,11]], [12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23]]) / Multi-dimensional to one-dimensional as shown in the figure:

The above content is how to get started with Numpy in python data analysis. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB Shulou Tech Info macOS OPPO Reno