title: Find the closest value to another value in a NumPy array
body: <p>I want to find the element in <code>yrs</code> that is closest to 2013 (<code>_tmp</code>). </p>
  
  <pre><code>yrs = [2000.0, 2001.0, 2002.0, 2003.0, 2004.0, 2005.0, 2006.0, 2007.0, 2008.0, 2009.0, 2010.0, 2011.0, 2012.0, 2014.0, 2015.0, 2016.0]
  _tmp = 2013
  min(yrs, key=lambda x: abs(x - _tmp))
  </code></pre>
  
  <p>I've tried with a list comprehension but it throws a <code>NameError</code>. How else can I do this? Perhaps with numpy?</p>