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`
