之前只见过列表list的append方法,昨天写代码的时候,看到了numpy库的append方法,记录一下。
简单的说,该方法功能就是将一个数组附加到另一个数组的尾部。
目录
官方帮助文档
参数
返回值
示例
axis无定义
axis=0的情况
axis=1的情况
axis=0和axis=1的图示
先看一个官方的帮助文档,嫌麻烦的可以直接看示例。看完示例再反过头看文档,其实理解的更好。
官方帮助文档
append(arr, values, axis=None)
Append values to the end of an array. 将值附加到数组的末尾。
参数
arr : array_like
Values are appended to a copy of this array. 值将附加到此数组的副本。
values : array_like
These values are appended to a copy of "arr". It must be of the correct shape (the same shape as "arr", excluding "axis"). If "axis" is not specified, "values" can be any shape and will be flattened before use.
这些值附加到"arr"的副本上。 它必须是正确的形状(与"arr"形状相同,不包括"轴")。 如果未指定