python - numpy中轴的长度是多少

标签 python numpy

我刚开始使用 numpy。 quick start tutorial说:

The coordinates of a point in 3D space [1, 2, 1] has one axis. That axis has 3 elements in it, so we say it has a length of 3. In the example pictured below, the array has 2 axes. The first axis has a length of 2, the second axis has a length of 3.

[[ 1., 0., 0.],  
 [ 0., 1., 2.]]

我没有收到“第一个轴的长度为 2,第二个轴的长度为 3”。我可以看到 [ 1., 0., 0.][ 0., 1., 2.] 都包含三个元素,那么为什么它们的长度不是 3 ?

最佳答案

您展示的示例还不错,但让您感到困惑。术语“轴”相当于“维度”。拿这个数组:

[[1, 2, 3],
 [4, 5, 6]]

这个数组是二维的。第一维或轴有两个元素的事实只是巧合。坐标轴不是 [1, 2, 3][4, 5, 6]

一个不太容易混淆的例子如下:

[[1, 2, 3],
 [2, 3, 4],
 [3, 4, 5],
 [4, 5, 6]]

这个数组也是二维的,只是第一维有4个元素。形状是(4, 3):4行,每行3列。

关于python - numpy中轴的长度是多少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64045963/

相关文章:

python - Pandas 从一个值中减去所有值,移动到下一个值并重复

python - Python 中的语法 (.T)

python - 这种NumPy列表理解的捷径

python - Wireshark 未检测到 TLS 连接

python - 返回 boolean 数组中 "false"值的索引

python - numpy数组的扁平化

python - 为 pip 提供 NumPy site.cfg 参数

python - Django Rest Framework Api 查看 GET

python - Jupyter 笔记本中 Matplotlib 图的比例图大小

python - Django 夹层导入错误 : No module named apps