Reputation: 131
I'm trying to get the row count of each LoanRange, right now the dataframe displays the count for "JobsRetained". The sum amount still needs to display for JobsRetained.
jobsByRange_df = ppp_df.groupby(["Industry", "LoanRange"])["JobsRetained"].agg(['count', 'sum'])
jobsByRange_df
This is the current DataFrame Display
Upvotes: 1
Views: 65
Reputation: 36
Not sure if this is what you want. Please, try this:
jobsByRange_df = ppp_df.groupby(["Industry", "LoanRange"]).agg(SumJobsRetained=('JobsRetained', 'sum'), CountLoanRange=('LoanRange', 'count'))
jobsByRange_df
If it doesn't work, could you please share your dataframe? It'd be helful to get a precise answer.
Upvotes: 1