《Python数据分析技术栈》第05章 06 矩阵(Matrices)

06 矩阵(Matrices)

《Python数据分析技术栈》第05章 06 矩阵(Matrices)

A matrix is a two-dimensional data structure, while an array can consist of any number of dimensions.

矩阵是一种二维数据结构,而数组可以包含任意维数。

With the np.matrix class, we can create a matrix object, using the following syntax:

通过 np.matrix 类,我们可以使用以下语法创建一个矩阵对象:

python 复制代码
x=np.matrix([[2,3],[33,3],[4,1]])
#OR
x=np.matrix('2,3;33,3;4,1') #Using semicolons to separate the rows x

Most of the functions that can be applied to arrays can be used on matrices as well. Matrices use some arithmetic operators that make matrix operations more intuitive. For instance, we can use the * operator to get the dot product of two matrices that replicates the functionality of the np.dot function.

大多数可用于数组的函数也可用于矩阵。矩阵使用一些算术运算符,使矩阵运算更加直观。例如,我们可以使用 * 运算符获取两个矩阵的点积,这与 np.dot 函数的功能相同。

Since matrices are just one specific case of arrays and might be deprecated in future releases of NumPy, it is generally preferable to use NumPy arrays.

由于矩阵只是数组的一种特殊情况,而且在未来的 NumPy 版本中可能会被弃用,因此通常最好使用 NumPy 数组。

相关推荐
子夜江寒15 分钟前
Python 学习-Day8-执行其他应用程序
python·学习
背心2块钱包邮23 分钟前
第7节——积分技巧(Integration Techniques)-代换积分法
人工智能·python·深度学习·matplotlib
一个散步者的梦1 小时前
一键生成数据分析报告:Python的ydata-profiling模块(汉化)
python·数据挖掘·数据分析
黑客思维者1 小时前
Python大规模数据处理OOM突围:从迭代器原理到TB级文件实战优化
开发语言·python·github·迭代器·oom
weixin_421133412 小时前
应用日志监控
python
语落心生2 小时前
餐饮供应链的数仓设计思考 (七) 数据产品与应用创新方案
数据分析
语落心生2 小时前
餐饮供应链的数仓设计思考 (六) 数据分析与业务预测方案
数据分析
CHANG_THE_WORLD3 小时前
Python 学习三 Python字符串拼接详解
开发语言·python·学习
测试老哥3 小时前
Postman接口测试基本操作
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman
winfredzhang3 小时前
基于wxPython的TodoList任务管理器开发详解
python·wxpython·todolist·持久