One of the most common questions people ask is which IDE/environment/tool to use while working on your data science projects. Plenty of options are available – from language-specific IDEs like R Studio, PyCharm to editors like Sublime Text or Atom – the choice can be intimidating for a beginner. If there is one tool that every data scientist should use or must be comfortable with, it is Jupyter Notebooks (previously known as iPython notebooks). In this article, you will learn all about Jupyter Notebooks!
Jupyter Notebook is a web app that lets us create and share codes and documents. It has an environment where we can run, document, visualize, and see the results of our code without leaving it. It is useful for doing data science workflows from start to finish.
Jupyter Notebooks are great for prototyping because we can run each cell of code separately. This lets us test a part of the code without running the whole script. I think Jupyter’s cell structure is better than other IDEs (like RStudio).
Jupyter Notebooks are flexible, interactive, and powerful for data scientists. We can use other languages besides Python, like R, SQL, etc. They are also good for showing codes in a teaching way.
Jupyter Notebook is a web-based application that enables you to create and share documents featuring live code, text, graphs, and other media. It serves various purposes like data analysis, data science, machine learning, education, and research. Supporting over 40 programming languages, including Python, R, Julia, and Scala, Jupyter Notebook facilitates diverse environments through different kernels. Its versatility and power for interactive computing are highlighted by several features:
– Code cells: You can write and execute Python code directly in the browser, observing immediate output. Code cells allow for running code cells and executing code seamlessly.
– Markdown cells: Utilizing Markdown syntax, you can incorporate explanatory text, headings, lists, links, images, and more, ensuring clear and attractive documentation and presentation of your work.
– Raw cells: These enable writing code not evaluated by the notebook kernel, yet convertible to other formats using nbconvert, enhancing flexibility in document creation.
– Notebook documents: Save your work as a notebook file (.ipynb) containing all code, text, and media elements. Additionally, export options like HTML, PDF, or slides broaden accessibility and sharing capabilities.
– Notebook web app: Access and edit your notebooks online via a web browser. Manage files, configure settings, install extensions, and execute Python code through the notebook server, all within the web app environment.
Jupyter Notebook serves as an example notebook for demonstrating data analysis, data science, and other applications of computer code, facilitating seamless execution of Python code and supporting various programming languages within a single interface. With its command mode and rich feature set, Jupyter Notebook stands as a versatile and indispensable tool for programming and interactive computing tasks.
As you might have guessed by now, you need to have Python installed on your machine first. Either Python 2.7 or Python 3.3 (or greater) will do.
For new users, the general consensus is that you should use the Anaconda distribution to install both Python and the Jupyter notebook. Anaconda installs both these tools and includes quite a lot of packages commonly used in the data science and machine learning community. You can download the latest version of Anaconda from here.
If, for some reason, you decide not to use Anaconda, then you need to ensure that your machine is running the latest pip version. How do you do that? If you have Python already installed, pip will already be there. To upgrade to the latest pip version, follow the below code:
#Linux and OSX
pip install -U pip setuptools
#Windows
python -m pip install -U pip setuptools
Once pip is ready, you can go ahead and install Jupyter:
#For Python2
pip install jupyter
#For Python3
pip3 install jupyter
You can view the official Jupyter installation documentation here.
We’ve now learned all about what these notebooks are and how to go about setting them up on our own machines. Time to get the party started!
To run your Jupyter notebook, simply type the below command and you’re good to go!
jupyter notebook
Once you do this, the Jupyter notebook will open up in your default web browser with the below URL:
http://localhost:8888/tree
In some cases, it might not open up automatically. A URL will be generated in the terminal/command prompt with the token key. You will need to copy paste this entire URL, including the token key, into your browser when you are opening a Notebook.
Once the Notebook is opened, you’ll see three tabs at the top: Files, Running and Clusters. Files basically lists all the files, Running shows you the terminals and notebooks you currently have open, and Clusters is provided by IPython parallel.
To open a new Jupyter notebook, click on the ‘New’ option on the right-hand side of the page.
In a Text File, you are given a blank slate. Add whatever alphabets, words and numbers you wish. It basically works as a text editor (similar to the application on Ubuntu). You also get the option to choose a language (there are a plethora of them given to you) so you can write a script in that. You also have the ability to find and replace words in the file.
In the Folder option, it does what the name suggests. You can create a new folder to put your documents in, rename it and delete it, whatever your requirement.
The Terminal works exactly like the terminal on your Mac or Linux machine (cmd on Windows). It does a job of supporting terminal sessions within your web browser. Type python in this terminal and voila! Your python script is ready to be written.
But in this article, we are going to focus on the notebook so we will select the Python 3 option from the ‘New’ option. You will get the below screen:
You can then start things off by importing the most common Python libraries: pandas and numpy. In the menu just above the code, you have options to play around with the cells: add, edit, cut, move cells up and down, run the code in the cell, stop the code, save your work and restart the kernel.
The developers have inserted pre-defined magic functions that make your life easier and your work far more interactive. You can run the below command to see a list of these functions (note: the “%” is not needed usually because Automagic is usually turned on):
%lsmagic
You’ll see a lot of options listed and you might even recognise a few! Functions like %clear, %autosave, %debug and %mkdir are some you must have seen previously. Now, magic commands run in two ways:
As the name suggests, line-wise is when you want to execute a single command line while cell-wise is when you want to execute not just a line, but the entire block of code in the entire cell.
In line-wise, all given commands must started with the % character while in cell-wise, all commands must begin with %%. Let’s look at the below example to get a better understanding:
Line-wise:
%time a = range(10)
Cell-wise:
%%timeit a = range (10)
min(a)
I suggest you run these commands and see the difference for yourself!
And the magic doesn’t stop there. You can even use other languages in your Notebook, like R, Julia, JavaScript, etc. I personally love the ‘ggplot2′ package in R so using this for exploratory data analysis is a huge, huge bonus.
To enable R in Jupyter, you will need the ‘IRKernel’ (dedicated kernel for R) which is available on GitHub. It’s a 8 step process and has been explained in detail, along with screenshots to guide you,
If you are a Julia user, you can use that within Jupyter Notebooks too! Check out this comprehensive article which is focused on learning data science for a Julia user and includes a section on how to leverage it within the Jupyter environment.
If you prefer working on JavaScript, I recommend using the ‘IJavascript’ kernel. Check out this GitHub repository which walks you through the steps required for installing this kernel on different OS. Note that you will need to have Node.js and npm installed before being able to use this.
Before you go about adding widgets, you need to import the widgets package:
from ipywidgets import widgets
The basic type of widgets are your typical text input, input-based, and buttons. See the below example, taken from Dominodatalab, on how an interactive widget looks like:
You can check out a comprehensive guide to widgets here.
Keyboard shortcuts are a fundamental feature of Jupyter Notebooks, streamlining tasks and enhancing efficiency. By pressing Ctrl+Enter, you can swiftly execute any code block, saving valuable time. Let’s delve into some essential shortcuts that significantly enhance your workflow:
Jupyter Notebook provides two distinct keyboard input modes: Command and Edit. Command mode, indicated by a grey cell border with a blue left margin, facilitates notebook-level commands. In contrast, Edit mode, signified by a green cell border, enables text or code input into the active cell.
Toggle between command and edit modes effortlessly using Esc and Enter, respectively. Try it now to experience the seamless transition!
– A: Insert a new cell above the active cell, while B inserts one below.
– Press D twice consecutively to delete a cell, and Z to undo the deletion.
– Transform the currently active cell into a code cell with Y.
– Select multiple cells by holding Shift and using the up or down arrow keys. While in multiple selection mode, merge your selection by pressing Shift + M.
– Instantly access the ‘Find and Replace’ menu with F.
Switch to edit mode (press Enter in command mode) to utilize these helpful shortcuts:
– Ctrl + Home: Navigate to the beginning of the cell.
– Save your progress promptly with Ctrl + S.
– Execute your entire cell block by pressing Ctrl + Enter.
– Add a new cell below the current one and execute it simultaneously with Alt + Enter.
– Open the command palette swiftly with Ctrl + Shift + F.
Explore the comprehensive list of keyboard shortcuts by pressing ‘H’ in command mode or navigating to Help > Keyboard shortcuts. Regularly check for updates as new shortcuts are frequently introduced.
Jupyter Notebook’s user-friendly interface, coupled with its extensive array of shortcuts, ensures a smooth and efficient coding experience, whether on your local machine or collaborating with other users. With rich text elements, markdown cells, and rich output, Jupyter Notebook remains the go-to tool for creating dynamic narratives and conducting data analysis in any runtime environment.
Extensions are a very productive way of enhancing your productivity on Jupyter Notebooks. One of the best tools to install and use extensions I have found is ‘Nbextensions’. It takes two simple steps to install it on your machine (there are other methods as well but I found this the most convenient):
Step 1: Install it from pip:
pip install jupyter_contrib_nbextensions
Step 2: Install the associated JavaScript and CSS files:
jupyter contrib nbextension install --user
Once you’re done with this, you’ll see a ‘Nbextensions’ tab on the top of your Jupyter Notebook home. And voila! There are a collection of awesome extensions you can use for your projects.
To enable an extension, just click on it to activate it. I have mentioned 4 extensions below that I have found most useful:
These are just some of the extensions you have at your disposal. I highly recommend checking out their entire list and experimenting with them.
This is one of the most important and awesome features of a Jupyter Notebook. When I have to do a blog post and my code and comments are in a Jupyter file, I need to first convert them into another format. Remember these notebooks are in json format and that isn’t really helpful when it comes to sharing it. I can’t go about posting the different cells blocks in an email or on the blog, right?
Go to the ‘Files’ menu and you’ll see a ‘Download As’ option there:
You can save your Notebook in any of the 7 options provided. The most commonly used is either a .ipynb file so the other person can replicate your code on their machine or the .html one which opens as a web page (this comes in handy when you want to save the images embedded in the Notebook).
You can also use the nbconvert option to manually convert your notebook into a different format like HTML or PDF.
You can also use jupyterhub, which lets you host notebooks on it’s server and share it with multiple users. A lot of top notch research projects use this for collaboration.
JupyterLab was launched in February this year and is considered the evolution of Jupyter Notebooks. It allows a more flexible and powerful way of working on projects, but with the same components that Jupyter notebooks have. The JupyterLab environment is exactly the same as a Jupyter Notebook, but with a more productive experience.
JupyterLab enables you to arrange your work area with notebooks, terminals, text files and outputs – all in one window!
You can see the installation instructions here if you want to try it out on your machine. The long term aim of the developers is for JupyterLab to eventually replace Jupyter notebooks. But that point is still a bit further away right now.
While solo projects offer enjoyment, teamwork often prevails, emphasizing the importance of adhering to guidelines and best practices to maintain consistency across code and Jupyter Notebooks. Here are essential pointers to uphold when working with Jupyter Notebooks:
By adhering to these best practices, you enhance collaboration, clarity, and overall efficiency within your team’s workflow, ensuring that your Jupyter Notebooks remain effective tools for code development and communication.
To convert your Notebook into slides, go to ‘View’ -> ‘Cell Toolbar’ and click on ‘Slideshow’. Boom! Each block of code now displays a ‘Slide Type’ drop-down option on the right. You will get the below 5 options:
Play around with each option to understand it better. It will change the way you present your code!
Python notebooks are an incredibly useful and effective tool for programmers, academics, and data scientists. They provide an interactive online environment where users can create and share documents with rich text, graphics, and live code. Programming languages such as Python, R, Julia, and others can be worked with easily with Jupyter Notebooks. The workflow is streamlined and efficiency is increased with Jupyter Notebooks’ capabilities, which include extensions, keyboard shortcuts, and magic functions. JupyterLab, the next step up from Jupyter Notebooks, promises an even more integrated and versatile experience, making it a vital tool for data science and research professionals.
A. What is the purpose of the Jupyter Notebook? Jupyter e-book notebook are useful for all data sciences tasks like exploratory data analytics (EDA), data cleaning and transformation.
A. Jupyter Notebooks are an integrated IDE. IDEs are places in which code can be written with support and functionality. Almost any IDE includes syntax-spotting, debugging and completion.
A. The Jupyter Notebook focuses on data science, whereas Python IDLE provides a development environment for writing code. Executes a Python program. Sept 7, 2025.
A. If you have a beginner’s experience in software programming, Jupyter Notebooks are an excellent place. The platform is aimed at supporting data science and supports 40 programming languages.
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
Wow such a wonderful article for a fresher
Glad you found it useful, Kamal. :)
A great article. Many thanks.
Thanks, Rahan!
I am learning Python now...This article will help me a lot think so...Can you please share some articles regarding MI and AI as well
Hi Thrilochan, All articles on Analytics Vidhya are machine learning focused. :) Are you looking for any specific domain or technique? I can help you out with that.
Hi Thrilochan, All the articles on Analytics Vidhya are machine learning focused. Are you looking for any specific domain or technique based articles? I can help you out with that. You can also check out the training platform to get started with your data science journey: https://trainings.analyticsvidhya.com/
Nice article. Data science is indeed an important subject to talk about.
A great article. Many thanks.
Great article. Thanks a lot
This article is very useful for beginners those who want to do python in jupyter. Very useful commands , tips and more.
thanks for this article pranav ..it really helps
Innovative detailed information get.. thanks!!!
Thanks Pranav, it was a nice article. I did not see anything about integration to online repositories especially GitHub. This is required for either code safety and collaboration or only for code safety
I don't get the Notebook Extensions! Any help ?
Hi Amna, Were you able to install using the steps provided?
I was not able to execute Step 7: install.packages(c('rzmq','repr','IRkernel','IRdisplay'), repos = 'http://irkernel.github.io/', type = 'source'). can you please suggest next steps. Error message: Warning: unable to access index for repository http://irkernel.github.io/src/con trib: cannot open URL 'http://irkernel.github.io/src/contrib/PACKAGES' Warning message: packages 'rzmq', 'repr', 'IRkernel', 'IRdisplay' are not available (for R versio n 3.5.1)
Hi Anupama, It seems the irkernel page has been updated hence that step as mentioned on the Discussion portal might not work. You can check out the irkernel page directly to see the installation instructions: https://irkernel.github.io/docs/