我必须找到从 hdf5 文件中读取的 NumPy 数组的模式。NumPy 数组是 1d,包含浮点值。
my_array=f1[ds_name].value
mod_value=scipy.stats.mode(my_array)
Run Code Online (Sandbox Code Playgroud)
我的数组是 1d,包含大约 1M 个值。我的脚本需要大约 15 分钟才能返回模式值。有什么办法可以让它更快吗?
另一个问题是为什么scipy.stats.median(my_array)模式有效时不起作用?
AttributeError: 模块 'scipy.stats' 没有属性 'median'