How to copy/paste a dataframe from iPython into Google Sheets or Excel?

Paste the output to an IDE like Atom and then paste in Google Sheets/Excel


Try using the to_clipboard() method. E.g., for a dataframe, df: df.to_clipboard() will copy said dataframe to your clipboard. You can then paste it into Excel or Google Docs.


If df.to_clipboard doesn't work. This will work.

import io
with io.StringIO() as buffer:
    df.to_csv(buffer, sep=' ', index=False)
    print(buffer.getvalue())

Then, you can copy the printed dataframe and paste it in Excel or Google Sheets.