Numpy教程(三)

1、迭代数组
2、数组操作

  • reshape()修改数组形状
import numpy as np
 
a = np.arange(8)
print (a)
print ('\n')

b = a.reshape(4,2)
print (b)
原始数组:
[0 1 2 3 4 5 6 7]

修改后的数组:
[[0 1]
 [2 3]
 [4 5]
 [6 7]]
  • 翻转数组
    numpy.transpose(arr, axes):对换数组的维度

  • 修改数组维度
    numpy.broadcast、numpy.broadcast_to、numpy.expand_dims、numpy.squeeze

  • 连接数组****
    concatenate、stack、hstack、vstack

  • 分割数组
    split、hsplit、vsplit

  • 数组元素的添加与删除
    append、resize、insert、delete、unique
    3、位运算
    4、字符串函数

发布了16 篇原创文章 · 获赞 3 · 访问量 6666

猜你喜欢

转载自blog.csdn.net/chilitian/article/details/84978878