NumPy 中包含了一个矩阵库 numpy.matlib,该模块中的函数返回的是一个矩阵,而不是 ndarray 对象

import numpy as np
a = np.arange(12).reshape(3, 4)
print(a)
print(a.T)
原数组:
[[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]]

转换数组:
[[ 0  4  8]
 [ 1  5  9]
 [ 2  6 10]
 [ 3  7 11]]

matlib.empty() 函数返回一个新的矩阵,语法格式为:

numpy.matlib.empty(shape, dtype, order)

shape: 定义新矩阵形状的整数或整数元组

Dtype: 可选,数据类型

order: C(行序优先) 或者 F(列序优先)

填充随机数据

import numpy.matlib 
import numpy as np
 
print (np.matlib.empty((2,2)))

Categories: python

0 Comments

发表评论

Avatar placeholder

邮箱地址不会被公开。 必填项已用*标注