Data Science, Python, Pandas.
another approach: we could write a custom function for processing aggregated data and use it with the groupby-apply combination. That way, we can overcome all the above issues quite easily. But then… the apply method works by concatenating all of the data output from the individually processed