'Is it possible to copy a cell from one jupyter notebook to another?
I am trying to copy cells from one jupyter notebook to another. How this is possible?
Solution 1:[1]
With jupyter 5.0.0, copy paste of one or many cells from one notebook to another works with Cmd C Cmd V (Mac).
For copying many cells together, select the first one then the last one with shift arrow (up or down).
The tool bar does not work for this purpose.
Solution 2:[2]
I have not done it myself though, but general practice is to avoid doing it as it can disturb the Cell JSON. It was not even possible until a few versions before. Recent Github posts has made it possible to do so though. Copy paste the cell in question to a code editor such as Atom or Sublime Text, make the changes you want to do and then paste it into the new Jupyter notebook. It should work.
Solution 3:[3]
For windows-
Use Ctrl + Shift + C to copy cells after selecting them using shift + arrow keys.
Then, switch to the notebook to which you want to copy the selected cells and go to command mode in it by pressing Esc key.
Then, use Ctrl + Shift + V to paste the cells in that notebook.
Note- I have not tested this on Linux but should work just as the procedure above.
Solution 4:[4]
VSCode can open and execute jupyter notebooks.
In the same software it is also possible to cut/copy and paste from one notebook to another (something that I didn't manage to do with jupyter notebook or lab).
It saved me a lot of time.
Solution 5:[5]
In JupyterLab, you can view two notebooks arranged as panes side-by-side. (Or even two views of the same notebook.)
Then you can select a cell or continuous range of them. When they are highlighted go to the top cell and click and drag over to the other notebook to copy them.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Varun Pius Rodrigues |
| Solution 3 | Swapnil Agarwal |
| Solution 4 | Vincenzooo |
| Solution 5 | Wayne |
