Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Jupyter: Shortcut to copy output of a cell

Tags:

python

jupyter

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?

like image 697
jim jarnac Avatar asked Jan 06 '17 01:01

jim jarnac


People also ask

How do you copy a cell output in Jupyter notebook?

Copying and pasting cells BETWEEN notebooks: Notebook 1: — Select multiple cells by holding down Shift and hit Ctrl+c to copy. Notebook 2: — Hit Esc to enter Command mode Ctrl + v to paste.

What is %% capture in Python?

Capturing Output With %%capture IPython has a cell magic, %%capture , which captures the stdout/stderr of a cell. With this magic you can discard these streams or store them in a variable.

How do I copy text from terminal Jupyter?

Copy/Paste For macOS users, Cmd+C and Cmd+V work as usual. For Windows users using PowerShell , Ctrl+Insert and Shift+Insert work as usual. To use the native browser Copy/Paste menu, hold Shift and right click to bring up the context menu (note: this may not work in all browsers).

How do you copy a code and output from a Jupyter notebook to Word?

You can do that by typing the path after writing cd(change directory) in the command prompt. This code will create the word file in the same folder where the Jupyter notebook is.


2 Answers

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)
like image 100
Anurag Sharma Avatar answered Oct 07 '22 17:10

Anurag Sharma


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

like image 20
Nitin Mohan Avatar answered Oct 07 '22 17:10

Nitin Mohan