【发布时间】:2019-10-18 11:01:25
【问题描述】:
假设我有以下 numpy 数组:
import numpy as np
from numpy import inf
x = np.array([1,2,3,4])
我想用无穷大替换该数组的第 j 个索引,例如
x[2] = inf
有什么方法可以实现吗?因为当我尝试时,我收到以下错误:
OverflowError: cannot convert float infinity to integer
感谢您的回答!
【问题讨论】: