我有两个大列表t
和y
,我想以一种性能的方式确定y
中的数据超过预定义的limit
,即>=limit
的时间和长度。你知道吗
该问题可用以下示例数据说明:
t = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
y = [8,6,4,2,0,2,4,6,8,6,4,2,0,2,4,6,8]
limit = 4
在本例中,代码应返回以下列表:
t_exceedance_start = [0,6,14]
t_how_long_above_limit = [2,4,2]
我希望这可以在Numpy
中非常优雅地实现,但没有发现如何实现。你知道吗
如有任何建议,我们将不胜感激。你知道吗
这里有一个矢量化的方法,利用布尔来提高性能效率-
相关问题 更多 >
编程相关推荐