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,

@jorisvandenbossche worth adding a tests_common.py in pandas/io ?
 I don't know if this is easy to test (as the home dir depends on where the tests are run, of course can reuse `expanduser` to just test that the feature is there), but if so, certainly a good idea to add a `io/tests/test_common.py`
 I now use isinstance instead of try/except to see whether the path might be expandable. I also tried rebasing the new version so it will only be two commits again but maybe my git knowledge is not good enough to do so, if that is necessary please let me know and I will read up/figure it out.

about testing, not sure if its good practice to test against builtins but we can test whether get_filepath_or_buffer() returns the same as os.path.expanduser given a string input and returns the StringIO given a non string input/url.

I will add some tests for that, thanks.
 That is what I meant with "I don't know how easy it is to test", as it is indeed not very useful to test builtin behaviour. But what we _can_ test, it just our API, the fact that the feature is there and will not accidentally be removed later on. So in that case, I think it is not bad to just reuse `expanduser`, or maybe just assure that something is added to the string)
 @hsperr This looks great! Could you please squash this into a single change? See [this page](https://github.com/pydata/pandas/wiki/Git-Workflows#git-rebase) if you're not quite sure what that means.
 @shoyer Thanks a lot for the link to the rebase page, I indeed did not feel super comfortable with that but I think I managed to squash/fixup everything into a single commit. I also took your version for the changelog, thanks! If there is anything more let me know and hope I can contribute more in the future! 
 Thanks @hsperr !
