I have a dataframe an example of which is below. In all, the dataframe is 928,571 rows. I am using Pandas groupby to calculate the mean SMM by sector, seasoned, and incentive use the below code. On a small dataset 200 rows it works fine. However, when aggregating the full pandas dataframe the calculation takes over 18 hours and still does not complete. I have tried several possible solutions I found on SO but not has helped. Any ideas would be appreciated as I will have to turn to a database solution using sql to execute python which seems like overkill for this problem. I feel there is a 'trick' here that I am missing.
ModelData = ModelViewData.groupby(
['sector', 'seasoned', 'incentive'],
as_index=False
)[['smm']].agg('mean')
data = {
'Sector': ['LLB', 'MLB', 'HLB'],
'Seasoned':['new', 'moderate', 'seasoned'],
'RPB': [80000, 125000, 175000],
'Incentive':[.25, .25, .25],
'SMM': [.006, .007, .008]
}