title: Return NaN with statistics.mean() when passed empty list
body: <p>Not sure if this is an appropriate question, but I was wondering what the best (simplest?) way to do this is. </p>
  
  <p>I want to return a <code>NaN</code>(not a number) value when I pass an empty column (or string) to the <code>statistics.mean()</code> function in Python. So, something like:</p>
  
  <pre><code>variable_mean = statistics.mean(data[column_name])
  </code></pre>
  
  <p>I want the <code>variable_mean</code> variable to equal the mean when the <code>pandas</code> dataframe has data points and <code>NaN</code> when it is empty (I have a for loop and each iteration has dataframes with different numbers of rows, sometimes there are no rows).</p>
  
  <p>Maybe I just need to do like:</p>
  
  <pre><code>if len(data) == 0:
     variable_name = float('nan')
  </code></pre>
  
  <p>But it seems like there must be a better way?</p>
  
  <p>Thanks!</p>