fix a indices bug for categorical-datetime columns
This is to fix a bug reported in #26859

- [x] closes #26859
- [ ] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry
