add test case when to_csv argument is sys.stdout
- [+] closes #21561
- [+] tests added / passed
- [+] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

Add new test case when to_csv argument is sys.stdout