Chenie21

2021-02-24   阅读量: 265

Python

Python Numpy数组遍历的两种方法

扫码加入数据分析学习群
  1. 直接遍历


    [a, b] = test.shape

    for i in range(a-1):

    for j in range(b-1):

    print(b[i][j])

    print(type(b))


2.使用 flat 属性 返回 numpy.flatiter对象(唯一获取flatiter的方式)

a = np.arange(4).reshape(2,2)

print(a)

f = a.flat

print(f)

for item in f:

print(item)


51.2826 1 0 关注作者 收藏

评论(0)


暂无数据

推荐课程

推荐帖子