remove NaN in categories checking

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

lgtm. ping on green. obviously we didn't have enough tests for this :< thanks @almaleksia 