Pandas reindex dates in Groupby

Solution 1:

There's probably a slicker way to do this but this works:

def reindex_by_date(df):
    dates = pd.date_range(df.index.min(), df.index.max())
    return df.reindex(dates).ffill()

df.groupby('id').apply(reindex_by_date).reset_index(0, drop=True)