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,
while testing the feature it looked like filepath_or_buffer can be a StringIO object which throws an exception in os.path.expanduser(), then I thought I'd stick to the convention like _is_url() or _is_s3_url() where they try to parse it as one and treat it otherwise on except.