TEST: Add test for #22541 to ensure that error does not occur again
- [x] closes #22541
- [x] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`

While searching for related issue for my other pull request, I found that this issue must have been fixed with another commit in the past (don't know when this issue was fixed).

I added a test to ensure that this error won't know occur in the future.
thanks @phofl 