Numpy 数组操作

https://docs.scipy.org/doc/numpy/reference/routines.array-manipulation.html

#基础的操作

方法描述
copyto(dst,?src[,?casting,?where])将一个数组的值拷贝到另一个数组

#改变数组型状

方法描述
reshape(a, newshape[, order])不该面原有数据条件下改变型状
ravel(a[, order])返回连续的平坦数组(一维)
ndarray.flat1维数组迭代器
ndarray.flatten([order])返回折叠成一维的数组

#数组转换

方法描述
moveaxis(a, source, destination)移动坐标轴位置
rollaxis(a, axis[, start])反向滚动坐标轴
swapaxes(a, axis1, axis2)交换两个坐标轴
ndarray.T相当于self.transpose(), 当维度小于1的会后返回自身
transpose(a[, axes])转置

#改变维度

方法描述
atleast_1d(*arys)将数组转换为1维
atleast_2d(*arys)以2维查看数组
atleast_3d(*arys)以3维查看数组
broadcastProduce an object that mimics broadcasting.
broadcast_to(array, shape[, subok])扩散数组到新形状
broadcast_arrays(*args, **kwargs)Broadcast any number of arrays against each other.
expand_dims(a, axis)扩展数组的形状
squeeze(a[, axis])移除维度

#转换为数组类

方法描述
asarray(a[, dtype, order])转换为数组
asanyarray(a[, dtype, order])转变为数组,但不对数组的子类进行转换
asmatrix(data[, dtype])转换为矩阵
asfarray(a[, dtype])返回一个浮点类型的数组
asfortranarray(a[, dtype])Return an array laid out in Fortran order in memory.
ascontiguousarray(a[, dtype])返回一个连续数组
asarray_chkfinite(a[, dtype, order])转换为数组,并检测空值和无限
asscalar(a)将1个值的数组转换为常量
require(a[, dtype, requirements])返回一个所需形状的数组

#连接数组

方法描述
concatenate((a1, a2, …)[, axis])连接两个数组
stack(arrays[, axis])连接数组的序列
column_stack(tup)列连接
dstack(tup)Stack arrays in sequence depth wise (along third axis).
hstack(tup)水平连接
vstack(tup)垂直连接

#分割数组

方法描述
split(ary, indices_or_sections[, axis])分割数组
array_split(ary, indices_or_sections[, axis])分割数组
dsplit(ary, indices_or_sections)以第三个轴分割数组
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_zeros(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度旋转数组

原文链接:https://docs.scipy.org/doc/numpy/reference/routines.array-manipulation.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值