[SciPy-user] finding values in a list?

josef.pktd@gmai... josef.pktd@gmai...
Sat Jul 11 16:22:44 CDT 2009


2009/7/11 Carlos "Guâno" Grohmann <carlos.grohmann@gmail.com>:
> Sorry if this is too simple or even OT, but say I have a list like
>
> [1,2,3,4,5,6,7,8,9]
>
> and I want to get the values just below and above a given value.
>
> So, if I enter 6.2, I get 6 and 7.
>
> but how?

maybe like this
>>> a = (np.array([1,2,3,4,5,6,7,8,9])-6.1)
>>> a[a>0].min() + 6.2
7.0
>>> a[a<0].max() + 6.2
6.0

Josef

>
> TIA
>
> Carlos
>
> --
> Carlos Henrique Grohmann - Geologist D.Sc.
> a.k.a. Guano - Linux User #89721
> ResearcherID: A-9030-2008
>
> http://digitalelevation.blogspot.com
>
> http://www.igc.usp.br/pessoais/guano
> _________________
> Can’t stop the signal.
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-user mailing list