15

Please see attached screenshot:enter image description here

In Jupyter Python: Is there a shortcut to copy the output of a cell to clipboard? (ie without having to manually select and ctrl-c?)

Alternatively is there a python function that instead of print would return its output directly in the clipboard for it to be pasted later?

jim jarnac
  • 4,804
  • 11
  • 51
  • 88
  • 1
    Maybe this solution is helpful: http://stackoverflow.com/questions/20821815/copying-the-contents-of-a-variable-to-the-clipboard – Benjamin Jan 06 '17 at 08:26
  • https://stackoverflow.com/questions/31610889/how-to-copy-paste-dataframe-from-stackoverflow-into-python – k1m190r Apr 30 '17 at 17:31

2 Answers2

8

You may use the following piece of code:

import pandas as pd
df = pd.DataFrame(['Copy me to clipboard'])
df.to_clipboard(index=False,header=False)
Venkatachalam
  • 16,288
  • 9
  • 49
  • 77
Anurag Sharma
  • 167
  • 1
  • 5
1

what i have done is ---file -->Print Preview , it opens the whole output in another tab than you can copy whatever you want