title: pandas fill missing dates in time series
body: <p>I have a dataframe which has aggregated data for some days. I want to add in the missing days </p>
  
  <p>I was following another post, <a href="https://stackoverflow.com/questions/19324453/add-missing-dates-to-pandas-dataframe">Add missing dates to pandas dataframe</a>, unfortunately, it overwrote my results (maybe functionality was changed slightly?)... the code is below</p>
  
  <pre><code>import random
  import datetime as dt
  import numpy as np
  import pandas as pd
  
  def generate_row(year, month, day):
      while True:
          date = dt.datetime(year=year, month=month, day=day)
          data = np.random.random(size=4)
          yield [date] + list(data)
  
  # days I have data for
  dates = [(2000, 1, 1), (2000, 1, 2), (2000, 2, 4)]
  generators = [generate_row(*date) for date in dates]
  
  # get 5 data points for each
  data = [next(generator) for generator in generators for _ in range(5)]
  
  df = pd.DataFrame(data, columns=['date'] + ['f'+str(i) for i in range(1,5)])
  
  # df
  groupby_day = df.groupby(pd.PeriodIndex(data=df.date, freq='D'))
  results = groupby_day.sum()
  
  idx = pd.date_range(min(df.date), max(df.date))
  results.reindex(idx, fill_value=0)
  </code></pre>
  
  <p>Results before filling in missing date indices<br>
  <a href="https://i.stack.imgur.com/Q3bkd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Q3bkd.png" alt="enter image description here"></a></p>
  
  <p>Results after<br>
  <a href="https://i.stack.imgur.com/8O1eI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8O1eI.png" alt="enter image description here"></a></p>