Jupyter Notebook tips, tricks, and shortcuts


Jupyter Notebook

Jupyter notebook, formerly known as the IPython notebook, is a flexible tool that helps you create readable analyses, as you can keep code, images, comments, formula, and plots together. Jupyter is quite extensible, supports many programming languages and is easily hosted on your computer or on almost any server — you only need to have ssh or http access. Best of all, it’s completely free.

Project Jupyter was born out of the IPython project as the project evolved to become a notebook that could support multiple languages – hence its historical name as the IPython notebook. The name Jupyter is an indirect acronym of the three core languages it was designed for: Julia, PYThon, and R , and is inspired by the planet Jupiter.

When working with Python in Jupyter, the IPython kernel is used, which gives us some handy access to IPython features from within our Jupyter notebooks (more on that later!)

 

Keyboard Shortcuts

As any power user knows, keyboard shortcuts will save you lots of time. Jupyter stores a list of keyboard shortcuts under the menu at the top: Help > Keyboard Shortcuts, or by pressing H in command mode (more on that later). It’s worth checking this each time you update Jupyter, as more shortcuts are added all the time.

Another way to access keyboard shortcuts and a handy way to learn them is to use the command palette: Cmd + Shift + P (or Ctrl + Shift + P on Linux and Windows). This dialog box helps you run any command by name – useful if you don’t know the keyboard shortcut for an action or if what you want to do does not have a keyboard shortcut. The functionality is similar to Spotlight search on a Mac, and once you start using it you’ll wonder how you lived without it!

 

Some of my favorites ones are presented below:

  • Esc will take you into command mode where you can navigate around your jupyter notebook with arrow keys no matter the types of computers on hand ( Linux or windows).
  • While in command mode:
    • A to insert a new cell above the current cell, B to insert a new cell below.
    • M to change the current cell to Markdown, Y to change it back to the code
    • D + D (press the key twice) to delete the current cell
  • Enter  will take you from command mode back into edit mode for the given cell.
  • Shift + Tab will show you the Docstring (documentation) for the object you have just typed in a code cell – you can keep pressing this shortcut to cycle through a few modes of documentation.
  • Ctrl + Shift + - will split the current cell into two from where your cursor is.
  • Esc + F Find and replace on your code but not the outputs.
  • Esc + O Toggle cell output.
  • Selecting  Multiple Cells at once use the Following handy methods:
    • Shift + J or Shift + Down selects the next sell in a downwards direction. You can also select sells in an upwards direction by using Shift + K or Shift + UpOnce cells are selected, you can then delete / copy / cut / paste / run them as a batch. This is helpful when you need to move parts of a notebook. You can also use Shift + M to merge multiple cells at once. This is super crazy cool right.

      I will come back with other handy methods i use every day when i play with data.  Until next enjoy reading and leave comments, please.

 

Advertisements