stats.reset_index(drop=True, inplace=True)
// Combine with original data
unique = data.groupby("group", as_index=False).apply(uniquecols)
unique.reset_index(drop=True, inplace=True)
missing = unique.columns - stats.columns
// Instead of a more expensive join, make sure the order is
After Change
unique = uniquecols(old)
missing = unique.columns - new.columns
u = unique.loc[[0]*len(new), missing].reset_index(drop=True)
df = pd.concat([new, u], axis=1)stats.append(df)
stats = pd.concat(stats, axis=0, ignore_index=True)
// Note: If the data coming in has columns with non-unique