Skip to content

Tag: python

pandas: combine size and sum in a single groupby?

I have a dataframe of houses, one row per house, that looks like this: And I want to end up with a table that looks like this: Currently I’m doing two separate groupby calls, and then joining them together: Is there a way I could do this with a single groupby? Answer Output: