title: numpy.select - IndexError: index 0 is out of bounds for axis 0 with size 0
body: <p>Using np.select, I am seeking to return index row of first value in df['price'] less than smallest value in df1['price'] above last value in df['averages']. However, when there are no rows in df1['price'] less than smallest value in df1['price'] above last value in df['averages'], instead of returning 'NaN', I get the following error: IndexError: index 0 is out of bounds for axis 0 with size 0</p>
  <p>Here is the code that I have constructed</p>
  <pre><code>shop = {'price': [90.5, 82.4, 81.6, 71.2, 56.9]}
  df1 = pd.DataFrame(shop, columns = ['price'])
  
  month_data = {'averages': [75.1, 72.0, 68.4, 52.5]}
  df = pd.DataFrame(month_data, columns = ['averages'])
  
  
  conditions = [
                (np.abs(df1['price']-df['averages'].iloc[-1])).argmin() == len(df1) - 1, # index row of smallest 'price' value above last 'averages' value == df1 length minus 1
                (np.abs(df1['price']-df['averages'].iloc[-1])).argmin() &lt; len(df1) - 1, # index row of smallest 'price' value above last 'averages' value &lt; df1 length minus 1
                ]
  
  results = [
                'NaN', # return 'NaN' if index row of smallest value in df['price'] above last df['averages'] value is equal  to df1 length minus 1
                df1[df1['price'].lt(np.abs(df1['price']-df['averages'].iloc[-1])).argmin()].index[0] # return index row of first value in df['price'] less than smallest value in df1['price'] above last value in  df['averages']
             ]
  
  price_idx = np.select(conditions, results, default='')
                
  </code></pre>
  <p>How can I return 'NaN' instead of the error when index 0 is out of bounds for axis 0 with size 0</p>