BUG: Fix Index construction when given empty generator (#21470).
- [ ] closes #21470 
- [ ] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry
