BUG: errors and segfaults in groupby cython transforms (#16771)
- [x] closes #16771 
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry
