Make to_csv return a string if no path or buffer is provided.

Fixes #6061.