Numpy数组操作

变形

  • numpy.ndarray.shape表示数组的维度,返回一个元组,这个元组的长度就是维度的数目,即 ndim 属性(秩)
  • numpy.ndarray.flat 将数组转换为一维的迭代器,可以用for访问数组每一个元素。
  • numpy.ndarray.flatten([order=‘C’]) 将数组的副本转换为一维数组,并返回。

转置

  • numpy.transpose(a, axes=None) Permute the dimensions of an array.
  • numpy.ndarray.T Same as self.transpose(), except that self is returned if self.ndim < 2.

维度

  • numpy.newaxis = None None的别名,对索引数组很有用。
  • numpy.squeeze(a, axis=None) 从数组的形状中删除单维度条目,即把shape中为1的维度去掉。

组合

  • numpy.concatenate((a1, a2, …), axis=0, out=None) Join a sequence of arrays along an existing axis.
  • numpy.stack(arrays, axis=0, out=None)Join a sequence of arrays along a new axis.
  • numpy.vstack(tup)Stack arrays in sequence vertically (row wise).
  • numpy.hstack(tup)Stack arrays in sequence horizontally (column wise).

拆分

  • numpy.split(ary, indices_or_sections, axis=0) Split an array into multiple sub-arrays as views into ary.
  • numpy.vsplit(ary, indices_or_sections) Split an array into multiple sub-arrays vertically (row-wise).
  • numpy.hsplit(ary, indices_or_sections) Split an array into multiple sub-arrays horizontally (column-wise).

平铺

  • numpy.tile(A, reps) Construct an array by repeating A the number of times given by reps.
  • numpy.repeat(a, repeats, axis=None) Repeat elements of an array.

增删

  • numpy.unique(ar, return_index=False, return_inverse=False,return_counts=False, axis=None) Find the unique elements of an array.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值