I have the following code which is working as desired with one exception
df['FPYear'] = df['First_Purchase_Date'].dt.year
Table2 = df.loc[df.Date.between('2014-01-01','2019-11-30')].groupby(df['FPYear'])[['New Customer', 'Existing Customer', 'revenue']].sum() #with date filters for table
# Table2 = df.loc[df.Date.between('2018-11-22','2018-11-30') & (df['Region'] == 'USA')].groupby(df['FPYear'])[['New Customer', 'Existing Customer', 'revenue']].sum() #with date filters for table
Table2['TotalCusts'] = Table2['New Customer'] + Table2['Existing Customer']
Table2['Cohort Size'] = Table['New Customer']
Table2['Repeat Rate'] = Table2['Existing Customer']/Table2['TotalCusts']
Table2['NewCust Rate'] = Table2['New Customer']/Table2['TotalCusts']
Table2['PCT of Total Yr'] = Table2['TotalCusts']/Table['New Customer']
Table2.loc['Total'] = Table2.sum(axis = 0) #this code totals all columns. the below calcs totals for some and average for others
cols = ["Repeat Rate", "NewCust Rate"]
diff_cols = Table2.columns.difference(cols)
Table2.loc['Total'] = Table2[diff_cols].sum().append(Table2[cols].mean())
print(Table2)
For the last line of the code,
Table2.loc['Total'] = Table2[diff_cols].sum().append(Table2[cols].mean())
rather than have it take the mean() of all other columns I'd rather add in customer functions (simple col x/ col y) but after trying a few different things I have been unable to do so.