sunsett的个人博客分享 http://blog.sciencenet.cn/u/sunsett

博文

list 使用numpy数组进行索引

已有 5178 次阅读 2019-10-30 15:47 |个人分类:python|系统分类:科研笔记

a=[1,2,3,4]

b=np.array([1,2,3])

以b 为索引,获取a中的值,按照常规的写法 a[b] 则会报错

TypeError: only integer scalar arrays can be converted to a scalar index

意思是索引(即numpy数组)的格式并不是 整型标量数组,正确的写法如下:、

np.array(a)[b]



https://blog.sciencenet.cn/blog-3409932-1204084.html

上一篇:Install: tensorflow2.0/1.4 -keras GPU windows
下一篇:[转载]sentinel-2数据批量下载
收藏 IP: 202.114.121.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-23 17:13

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部