Python在数组最大值之后找到最小值 [英] Python find minimum after maximum of array
本文介绍了Python在数组最大值之后找到最小值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的, 我有一个像图片一样的数组列表:[100,200,150,300] 我想找到第一个最小值之后的第一个最大值, 例如,在图片中,我想找到150个最小数组.
Hi dears, I have a array list like picture: [100,200,150,300] I want to find first minimum after first maximum, As example in the picture i want to find 150 as minimum of array.
推荐答案
scipy中有一个名为argrelextrema的软件包.您可以使用它.
There is a package in scipy named argrelextrema. You can use that.
import numpy as np
from scipy.signal import argrelextrema
x = np.array([100,200,150,300])
# for local minima
x[argrelextrema(x, np.less)]
array([150])
这篇关于Python在数组最大值之后找到最小值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文