title: calculate sunrise and sunset times from a datetime index using ephem in Python
body: <p>I have a daily time series with <code>DateTime</code> index. I want to calculate the sunrise and sunset times for each day in the DataFrame. The result will be presented in columns <code>rise</code> and <code>set</code>. Below is my script using pyephem:</p>
  
  <pre><code>import ephem
  import datetime
  
  AliceS = ephem.Observer()
  AliceS.lat = '-23.762'
  AliceS.lon = '133.875'
  
  AliceS.date = df.index
  
  sun = ephem.Sun()
  
  df['rise'] = ephem.localtime(AliceS.next_rising(sun))
  df['set'] = ephem.localtime(AliceS.next_setting(sun))
  </code></pre>
  
  <p>This raises</p>
  
  <pre><code>ValueError: dates must be initialized from a number, string, tuple, or datetime
  </code></pre>
  
  <p>I believe that the cause of the error is <code>AliceS.date = df.index</code>, but I don't know how to fix it.</p>
  
  <p>Below is an example of the datetime index:</p>
  
  <pre><code>DateTime
  2016-04-02
  2016-04-03
  2016-04-04
  2016-04-07
  2016-04-08
  </code></pre>