ensure consistent structure for groupby on index and column
- [x] closes #17681
- [ ] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`

Thanks for the PR! But I think this was already covered in #29124