Scratchpad Add-in for Jupyter Notebooks and Google Colab

Author:Murphy  |  View: 29031  |  Time: 2025-03-23 19:58:52

I've been using Jupyter notebooks to develop ideas and explore data for the past several years. Of the many convenient add-ins available, there is one that I've so thoroughly integrated into my workflow that I immediately add it when I start using a different computer. It's the Scratchpad, pictured below.

Screenshot of using the Jupyter Notebook Scratchpad extension. Screenshot by author

As you're developing new code and exploring data, you may find that you want to make a quick test to see if a code snippet works. Or maybe you want to output something, but doing so in your current working cell would disrupt something else. With a scratchpad, it's super convenient to simply press ctrl+B and have a new cell pop up. I use this feature almost more than anything else. Not only is it nicer for keeping extra cells out of my code and forgetting that they're there, but it's also faster – just a couple taps of ctrl+B to open and close, as opposed to adding and deleting new cells and scrolling up and down a page. It's almost like having a dual monitor for your Jupyter Notebook.

There are plenty of tutorials showing you how to download and add this extension (go ahead and explore the other unofficial extensions while you're at it, and let me know if there are any that you love!). I wouldn't have written this post, except for one reason. I recently have been using Google Colab far more frequently, and was frustrated that there didn't seem to be a way to get the same functionality. It almost was enough to make me not use Colab. I tried to find a workaround with a few Google searches, but the "Scratchpad" I came across was nothing like what I was looking for. Then I stumbled across something with similar functionality. Now, at the time of writing this post, it's not as fast as getting the scratchpad in Jupyter Notebooks, but at least it's there! It certainly still keeps my final code cleaner, and I don't have any cells sitting around that I've forgotten about that end up messing up the flow later on.

1) In an open Colab notebook, select a cell and select the pop-out window icon, shown below.

Screenshot by author

2) This opens up a side window that copies the lines from the cell you're working on. If you edit code in here, it transfers to the working cell. It's not quite the same as an unconnected scratchpad that I find useful for testing code. You have to select the pop-out window icon again.

Screenshot by author

3) This opens up the cell that you can use freely as a test cell, and works just like the scratchpad version in Jupyter. Now you can code away!

Screenshot by author

That's it! I hope this post becomes obsolete soon and there will be a keyboard shortcut to access this feature, but if you're like me and use Scratchpad more than anything else, this is a viable option for if you're using Colab. Feel free to connect with me on LinkedIn, and let me know what other extensions help in your workflow. Hopefully this one will help you out as you tackle some projects similar to ones I've done!

Tags: Colab Google Colab Jupyter Notebook Python scratchpad

Comment