Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get started with Numpy in python data Analysis

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report