numpy array TypeError: only integer scalar arrays can be converted to a scalar index
程序员文章站
2024-03-02 21:27:58
...
This appears to be an issue with the latest version of Numpy. A recent change made it an error to treat a single-element array as a scalar for the purposes of indexing.
我的方法是在数组后加上.flatten()
举例:
#原代码
print("The ball picked:", ", ".join(map(lambda x: observations[x], seen)))
#更改后
print("The ball picked:", ", ".join(map(lambda x: observations[x], seen.flatten())))
推荐阅读
-
numpy array TypeError: only integer scalar arrays can be converted to a scalar index
-
moviepy音视频剪辑:AudioClip帧处理时报TypeError: only size-1 arrays can be converted to Python scalar错
-
TypeError: only integer scalar arrays can be converted to a scalar index
-
moviepy音视频剪辑:AudioClip帧处理时报TypeError: only size-1 arrays can be converted to Python scalar错