In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to use numpy in Python", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "how to use numpy in Python" this article.
Basic operation of 1.numpy
#! / usr/bin/env python
# coding:utf-8
Import numpy as np
Array = np.array ([[1, 2, 3], [4, 5, 5, 6])
Print (array)
Print ('Dimension:', array.ndim) # has several lines
Print (array.shape) # (2,3) has several rows and columns
Print ('size:',array.size) # Total size
A = np.array ([2jing3jin4], dtype=np.int64) # define type int64
Print (a.dtype)
A = np.zeros ((3p4)) # defines a matrix with three rows and four columns, all of which are 0
A = np.ones ((3p4)) # generates a matrix with three rows and four columns with a value of 1
A = np.empty ((3p4)) # generates a matrix with three rows and four columns with a value of 0
A = np.arange (1 and 10) # generate a matrix with steps from 1 to 9 to 2
A = np.arange (10) # generates a matrix from 0 to 9
A = np.arange (12). Reshape (3p4) # generates a sequence of three rows and four columns
A = np.linspace (1pm 10jue 6). Reshape (2pm 3) # generates a 6 segment with 2 rows and 3 columns between 1 and 10
A = np.array ([10, 20, 30, 40])
B = np.arange (4) # generate a matrix of four digits between 0 and 3, that is, a matrix of four arrays between 0 and 3
Print (aformab) # print a matrix
Addition of print (a b) # matrices
Print (aMub) # Matrix correlation
Print (aqb) # matrix multiplication
Print (aplomb) # Matrix multiplier
2. Numpy matrix operation
C = np.sin (a) * 10 # take sin for each value in a, then multiply by 10, con, tan are all like this
Print (c)
Print (b)
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.