Jupyter notebooks provide an effective way to develop, document, execute and communicate your results. Here are few tips and tricks to make your life easier while working on notebooks in Data Science Experience.
Jupyter notebooks have two different modes,
To enter the
EDIT mode, press
ENTER on your keyboard or click in a cell. Edit mode can be identified by green border around the cell with green left margin. When you are in the edit mode, you can type in the cells.
To enter the
COMMAND mode press
ESC or click anywhere outside the cell. You will see grey border around the cell with blue left margin. When you are in Command mode, you can edit your notebook but you can’t type in the cells.
Navigation in the Notebook
You can perform different actions on notebooks using your
You can use mouse to perform any action on your notebook from Menu bar or Tool bar as per your preference.
Those who prefer keyboard can use keyboard shortcuts. Here are few examples of keyboard shortcuts.
- Command Mode:
- Edit Mode:
- Run selected cell:
- Run cell and insert below:
- Run cell and select below:
- Insert cell above:
- Insert cell below:
- Cut selected cells:
- Copy selected cells:
For more keyboard shortcuts, you can refer Help -> Keyboard Shortcuts from Menu bar.
Magic in the Notebook
Do you know, you can run code in different languages in different cells within your notebook? If you want to see what all magic commands you can use within your notebook, just run
%lsmagic in one of the cells.
% matplotlib inline to show matplotlib plots inline the notebook.
%%writefile to write content of the cell to a file and
%run before the name of the file to execute the script.
Few other examples of cell magic:
- To render cell contents as LaTeX:
- To render cell contents as Html:
- To run cell with bash commands:
You can try different commands from above list and experiment with magic.
Getting help inside the notebook
Finally, if you need any help in the notebook just type in your function name and append
?. Notebook will give you required information about function with example.
Additionally, there are features in Jupyter to help with code completion. For example, if you need to see parameters for a function inside a notebook, after you open the parentheses for the function call you can press
TAB to show the docstring.
You can also use code completion to help end names of variables or functions in your environment by starting to type the name of the object and pressing
To test out these tips and tricks sign up for a for a free trial of Data Science Experience. For more informative blogs keep an eye on Data Science Experience Blog. Feel free to share your notebook on social media and don’t forget to add your friends in your project as collaborators.
Happy exploring Data Science Experience!