2024-10-04 11:26:35 发布
网友
我是新来的纽比,但我似乎不能让这段代码工作。在
item3.apply(lambda x : (x[np.isneginf(x)] = 0))
item3是一个numpy数组的向量,每个数组中有300个维度。在
引发的错误是无效语法。如何实现这个功能。在
但是,假设它是一个float64 numpy向量的向量。数据类型为object。它引发了一个例外
Item3是一个列,其中包含每个元素的维度为300
你可以做这样的东西:
import numpy as np from numpy import inf x = np.array([inf, inf, 0]) # Create array with inf values print x # Show x array x[x == inf] = 0 # Replace inf by 0 print x # Show the result
{a1}
你可以做这样的东西:
{a1}
相关问题 更多 >
编程相关推荐