dimanche 31 juillet 2016

Find numpy array values bounding an input value

I have a value, say 2016 and a numpy array: [2005, 2010, 2015, 2020, 2025, 2030]. What is the pythonic way to find the 2 values in the array that bound 2016. In this case, the answer will be an array [2015, 2020].

Not sure how to do it other than loop, but hoping for a more numpy based solution

Aucun commentaire:

Enregistrer un commentaire