import numpy as np
# a = np.array([1,2,3], dtype =np.int )
# a = np.array([[1,2,3],[3,4,5]] , dtype =float ) # Setting precision Set up 64 Only use np.float64
# a = np.zeros((3,5),dtype = np.int64)
# a = np.ones((3,4), dtype = np.int64)
# a = np.empty((3,4), dtype = np.int16)
# a = np.empty((3,4))
# a = np.full((3,4),2) # Specify all values of the matrix
# a = np.arange(10,20)
# a = np.arange(20)
# a = np.arange(20).reshape((5,4))
a = np.linspace(1, 5, 20).reshape((5, 4)) # Line segment , from 1 To 10 piecewise
print(a)
print(a.dtype)
a.fill(2) # You can also use it directly numpy Medium fill fill 2
print(a)
# print(help(np.empty))
import numpy as np
a = np.array([[1, 2, 3], [5, 9, 8]])
print(a)
print("number of dim:", a.ndim) # dimension
print("shape:", a.shape)
print("size:", a.size)
import numpy as np
#
# #a = np.array([1,11,1])
# a = np.array([[1,11,1],[2,3,4]])
#
#
# b = np.arange(6).reshape(3,2)
#
#
# print(a<5) # The judgment logic symbol directly outputs bool type
# print(a ==5)
#
# print(a)
# print(b)
#
# #c = a*b // Number and number multiplication Premise : Homomorphic matrices
# #c = b**2
# #c =a - b
# #c = a -b
# #c = np.dot(a,b) // matrix multiplication perhaps
# #c = a.dot(b)
# #c = np.cos(a) * 100
#
#
# print(c)
a = np.random.random((2, 4))
# print(np.max(a))
# print(np.sum(a))
# print(np.min(a))
print(np.max(a, axis=0)) # axis Axis by 1 For the line 0 Column
print(np.sum(a, axis=1))
print(np.min(a, axis=1))
print(a)
import numpy as np
a = np.arange(15, 3, -1).reshape((3, 4))
print(np.argmax(a)) # Maximum index argument of a function
print(np.argmin(a)) # Minimum index
# Average ( It can also be set to calculate by row and column )
print(np.mean(a))
print(a.mean())
# The old version
print(np.average(a))
# I won't support it
# print(a.average)
# Median
print(np.median(a))
# Add up the previous values
print(np.cumsum(a)) # Cumulative sum The accumulation of and
# Output is not 0 Rows and columns of
print(np.nonzero(a))
# The difference between the two
print(np.diff(a))
# Every line ( Column ) Sort
print(np.sort(a, axis=0))
# Transposition
print(np.transpose(a))
print(a.T.dot(a))
# Leave only values in the range
print(np.clip(a, 5, 9))
print(a)
Updating —
One 、 Environment configuratio
Scrapy Is applicable to Python