backport groupby