s = (pd.MultiIndex.from_tuples([[x, d] for x, y in df.groupby("Id")["Dt"] for d in pd.date_range(min(y), max(df["Dt"]), freq="MS")], names=["Id", "Dt"])) print (df.set_index(["Id", "Dt"]).reindex(s, fill_value=0).reset_index())