Now Reading
Top Jupyter Hacks & Tricks You Should Try

Top Jupyter Hacks & Tricks You Should Try

Rohit Chatterjee
Jupyter

Since we have recently shared an article on tricks and hacks of Google Colab, it is only fair that similar information is explored around Jupyter notebook to help data scientists navigate it easily. With the period of lockdown getting extended further, the available time could be a boon for several data scientists to become more efficient with Jupyter notebook projects. Before moving to the tricks and hacks, let us first understand what Jupyter notebook is. 

Jupyter notebook is an open-source web application that allows a user to create and share documents that contain live code, equations, visualisations and narrative text. It also consists of other features, such as:

  • Data cleaning and transformation 
  • Numerical simulation 
  • Statistical modelling
  • Data visualisation 
  • Machine learning

Now that we have covered the basics of Jupyter notebook, let us proceed to the tricks and hacks you should try.



Theme Change

If you have read our article on tricks and hacks of Google Colab, you already know why this point is important. Data scientists spend their entire day glued to the monitor with thousands of codes and the same interface, which may get monotonous over time. So much so, that frustration could lead to less productivity or errors that could have been avoided. When it comes to Google Colab, a few themes are already preinstalled, so a user does not have to enter codes to change a theme. Unfortunately, Jupyter notebook misses on this feature, and thus, coding is required. To change the theme, follow these steps mentioned below:

  • Install themes with the help of anaconda or pip:-

            anaconda- conda install -c conda-forge jupyterthemes


W3Schools

            pip- pip install jupyterthemes

  • Check the theme list- jt – l
  • Theme Select- jt -t chesterish
  • Restore default theme- jt -r

Change Cell Width

Data scientists usually work with monitors with high resolution. Thus, they may need to expand cell width to use the extra space, which can be done quickly with a simple method on Jupyter notebook.

  • Install Jupyter themes using anaconda and pip

anaconda- conda install -c conda-forge jupyterthemes

pip- conda install -c pip install jupyterthemes 

  • Alter the theme, cell width and cell height as per preference using:

jt -t chesterish -cellw 100% lineh 170

Jupyter Nbviewer To Share Notebooks

While working on Jupyter notebook, everyone will need to find a way to share their work with people. To ease this process, enter the nbviewer.

Nbviewer is a web application that enables users to enter a URL of a Jupyter Notebook file. Once entered, it renders the notebook into a static HTML web page. Once the rendering process is completed, it provides a user with a stable link to that page which can be shared with others. 

Nbviewer is not the only option, however. One can use Binder as well to open a static webpage.

See Also
Benchmark Analysis of Popular Image Classification Models

Converting Notebooks Into Slides

Converting notebooks into slides is a job done by almost everyone to share the notebook in a presentable format. To complete this conversion, several tools are often used. But these tools are not required, since Jupyter provides users with Nbconvert.

Nbconvert can be used to convert any ipynb file into other static formats such as HTML, LaTeX, PDF, and more.

Let us take a look at how you can convert a notebook into slides using Nbconvert:

  • Open notebook
  • Go to toolbar
  • Click on view>>slideshow

Each cell will have a slide-type on the right-hand corner, which needs to be selected as per the content.

  • Go to common terminal and type- jupyter nbconvert [file_name] –to slides

One can find “[file_name.html] where the code is being run in the folder. Open the file and change the slides by using the keys.

Run Python Profiler

Running Python Profiler is an easy task on Jupyter notebook with the help of %prun. A python profiler provides several function calls and execution time, along with other information such as:

  • ncalls 
  • tottime 
  • percall 
  • cumtime
  • percall 

Provide your comments below

comments

Copyright Analytics India Magazine Pvt Ltd

Scroll To Top