ENH: Expanduser in to_file methods GH9066

closes #9066
 
First time contributor, tried to follow all rules as good as possible.
If something is missing please let me know.

As specified in task 9066 tilde in a pathname get resolved into a absolute path.
In case the object is a buffer the buffer will be returned.

I did not add additional tests, since I could not find any module explicitly testing pandas/io/common.py
if that is necessary please let me know how to do that. The current tests are passing on my system and seem to cover the method below.

Best Regards,
Hey thank you for the note, I will fix that and use the isinstance version.