数组处理程序
基本操作
方法 |
描述 |
copyto(dst, src[, casting, where]) |
将值从一个数组复制到另一个数组,并根据需要进行广播。 |
改变数组形状
类转置操作
更改维度数
改变数组的种类
方法 |
描述 |
asarray(a[, dtype, order]) |
将输入转换为数组。 |
asanyarray(a[, dtype, order]) |
将输入转换为ndarray,但通过ndarray子类。 |
asmatrix(data[, dtype]) |
将输入解释为矩阵。 |
asfarray(a[, dtype]) |
返回转换为浮点类型的数组。 |
asfortranarray(a[, dtype]) |
返回以Fortran顺序排列在内存中的数组(ndim> = 1)。 |
ascontiguousarray(a[, dtype]) |
返回内存中的连续数组(ndim> = 1)(C顺序)。 |
asarray_chkfinite(a[, dtype, order]) |
将输入转换为数组,检查NaN或Infs。 |
asscalar(a) |
将大小为1的数组转换为其等效的标量。 |
require(a[, dtype, requirements]) |
返回提供的类型满足要求的ndarray。 |
组合数组
拆分数组
方法 |
描述 |
split(ary, indices_or_sections[, axis]) |
将数组拆分为多个子数组,作为ary的视图。 |
array_split(ary, indices_or_sections[, axis]) |
将一个数组拆分为多个子数组。 |
dsplit(ary, indices_or_sections) |
沿第3轴(深度)将数组拆分为多个子数组。 |
hsplit(ary, indices_or_sections) |
水平(按列)将一个数组拆分为多个子数组。 |
vsplit(ary, indices_or_sections) |
垂直(行)将数组拆分为多个子数组。 |
平铺数组
方法 |
描述 |
tile(A, reps) |
通过重复A代表次数来构造一个数组。 |
repeat(a, repeats[, axis]) |
重复数组的元素。 |
添加和删除元素
方法 |
描述 |
delete(arr, obj[, axis]) |
返回一个新的数组,该数组具有沿删除的轴的子数组。 |
insert(arr, obj, values[, axis]) |
沿给定轴在给定索引之前插入值。 |
append(arr, values[, axis]) |
将值附加到数组的末尾。 |
resize(a, new_shape) |
返回具有指定形状的新数组。 |
trim_zeross(filt[, trim]) |
修剪一维数组或序列中的前导和/或尾随零。 |
unique(ar[, return_index, return_inverse, …]) |
查找数组的唯一元素。 |
重新排列元素
方法 |
描述 |
flip(m[, axis]) |
沿给定轴颠倒数组中元素的顺序。 |
fliplr(m) |
左右翻转数组。 |
flipud(m) |
上下翻转阵列。 |
reshape(a, newshape[, order]) |
在不更改数据的情况下为数组赋予新的形状。 |
roll(a, shift[, axis]) |
沿给定轴滚动数组元素。 |
rot90(m[, k, axes]) |
在轴指定的平面中将阵列旋转90度。 |