小编782*_*219的帖子

将 math.erf 应用于数组

我正在使用 math.erf 来查找数组中每个元素的误差函数。

# Import the erf function from the math library
from math import erf
# Import the numpy library to represent the input data
import numpy as np

# Create a dummy np.array
dummy_array = np.arange(20)

# Apply the erf function to the array to calculate the error function of each element
erf_array = erf(dummy_array)
Run Code Online (Sandbox Code Playgroud)

我收到错误,因为我无法将整个函数应用于数组。有没有办法将误差函数应用于整个数组(矢量化方法),而无需循环遍历每个元素并应用它?(由于表很大,循环将花费很多时间)

python numpy function vectorization pandas

2
推荐指数
1
解决办法
3336
查看次数

标签 统计

function ×1

numpy ×1

pandas ×1

python ×1

vectorization ×1