import pandas as pd
import numpy as np
df = pd.DataFrame({'product': list('aaaabbbbcccc'), 'week': [1, 2, 3, 5, 1,
    2, 3, 5, 1, 2, 3, 4], 'sales': np.power(2, list(range(12)))})
df = df.set_index('week')

def reindex_by_max_index_of_group(df):
    index = list(range(1, max(df.index) + 1))
return df.reindex(index, fill_value=0)
df = df.groupby('product').apply(reindex_by_max_index_of_group)
df.drop(['product'], inplace=True, axis=1)
print(df.reset_index())
Pandas rolling sum with unevenly spaced index