5 Jupyter Hacks That You Never Knew Even Existed | by Avi Chawla | Mar, 2023


Photo by Sigmund on Unsplash

Jupyter Notebook is one of the most sought-after IDEs for almost all Python-oriented programming tasks such as data science, machine learning, scientific computing, and many more.

Its interactive coding capabilities make it the go-to tool not only for beginners but experts as well.

Yet, despite its widespread usage, many of its users do not use it to its full potential.

As a result, they tend to use Jupyter using its default interface/capabilities, which, in my opinion, can be significantly improved to provide a richer experience.

Therefore, in this article, I will present 5 cool Jupyter hacks that you probably never knew even existed.

These will allow you to unlock new levels of productivity and creativity with this powerful tool.

Let’s begin 🚀!

Often when we load a DataFrame in Jupyter, we preview it by printing. This is shown below:

However, it hardly tells anything about what’s inside this data.

As a result, one has to dig deeper by analyzing it, which involves simple yet repetitive code.

Instead, use Jupyter-DataTables. You can install it as follows:

To use it, run the following code in Jupyter:

It supercharges the default preview of a DataFrame with many useful features.

As a result, whenever you print a DataFrame, it will appear much more elegant as shown below.

This richer preview provides sorting, filtering, exporting, and pagination operations along with column distribution and data types

Not all data you get is labeled beforehand.

Thus, typically with unlabeled data, one may have to spend some time annotating/labeling it.

Rather than previewing the files externally and labeling them or building a complex annotation pipeline, you can annotate in just a few lines of code using 𝐢𝐩𝐲𝐚𝐧𝐧𝐨𝐭𝐚𝐭𝐞.

It provides a Jupyter widget specifically for data annotation.

Run the following commands to install it:

Data annotation becomes easier by clicking buttons. Thus, ipyannotate allows you to attach data labels to buttons.

Consider we have some images of cats and dogs (unlabeled). We can create an annotation pipeline as follows:

As shown above, you can annotate your data by simply clicking the corresponding button.

What’s more, you can also retrieve the labels and use them for your data pipeline as required.

While working in Jupyter, it is common to forget the parameters of a function and visit the official docs (or StackOverflow).

However, you can view the documentation in the notebook itself.

Pressing 𝐒𝐡𝐢𝐟𝐭-𝐓𝐚𝐛 opens the documentation panel. This is extremely useful and saves time as one does not have to open the official docs every single time.

A demo is shown below:

This feature also works for your custom functions.

After running some code in a Jupyter cell, we often navigate away to do some other work in the meantime.

Here, one has to repeatedly get back to the Jupyter tab to check whether the cell has been executed or not.

To avoid this, you can use the %%𝐧𝐨𝐭𝐢𝐟𝐲 magic command from the 𝐣𝐮𝐩𝐲𝐭𝐞𝐫𝐧𝐨𝐭𝐢𝐟𝐲 extension.

As the name suggests, it notifies the user upon completion (both successful and unsuccessful) of a Jupyter cell via a browser notification.

To install it, run the following command:

Next, load the extension:

And done!

Now, whenever you want to get notified, enter the following magic command at the top of the cell:

Whenever the cell will finish its execution, you will receive the following notification:

Clicking on the notification will take you back to the Jupyter tab.

While using Jupyter, we typically print many details to track the code’s progress.

However, it gets frustrating when the output panel has accumulated a bunch of details, but we are only interested in the most recent output.

Moreover, scrolling to the bottom of the output each time can be annoying too.

To clear the output of the cell, you can use the 𝗰𝗹𝗲𝗮𝗿_𝗼𝘂𝘁𝗽𝘂𝘁 method from the 𝗜𝗣𝘆𝘁𝗵𝗼𝗻 package.

IPython comes pre-installed with Python, so no installation is required.

You can import the method as follows:

When invoked, it will remove the current output of the cell, after which you can print the latest details.

A demo is shown below:

As demonstrated above, we only see the latest output in the cell. The previous outputs are being erased.

Although the above-mentioned tips will significantly enrich your Jupyter experience, there are still many things that I struggle to do with Jupyter.

For instance, Jupyter sucks when it comes to collaboration. As it runs locally, there is no way to embed real-time collaboration capabilities in Jupyter where teams can work together, add comments, track progress, etc.

What’s more, sharing is equally painful. If I ever have to share my notebook with someone, the only way to do that is by emailing them or hosting it online, on GitHub, for instance, and sharing the link.

Lastly, many data science tasks are not just limited to Python. They equally involve SQL, which is largely used to interact with organizational databases.

However, integrating SQL in Jupyter is feasible but a tedious process.

Solution

Frustrated with these limitations, I started looking for alternatives, and I am glad I discovered Deepnote.

Without having to learn anything new about how to use it, it took away all the limitations of Jupyter in a snap and has consistently offered me an enriching Jupyter-like experience.

Sharing, collaborating, using SQL, creating charts without any code, connecting to a database, etc., everything is seamlessly integrated into Deepnote.

While I understand that Jupyter tends to offer a generalized experience for all Python users, it miserably fails to address all the pain points of data scientists, especially those working in teams.

Deepnote, in my opinion, is a supercharged version of Jupyter for all data-driven projects, and you should definitely check it out.

With this, we come to the end of this blog.

Congratulations on learning a few incredible hacks for Jupyter notebook. I am sure these tips will level up your python programming productivity.

Also, I would love to know what are your favorite hacks while using Jupyter notebook.

As always, thanks for reading!


Photo by Sigmund on Unsplash

Jupyter Notebook is one of the most sought-after IDEs for almost all Python-oriented programming tasks such as data science, machine learning, scientific computing, and many more.

Its interactive coding capabilities make it the go-to tool not only for beginners but experts as well.

Yet, despite its widespread usage, many of its users do not use it to its full potential.

As a result, they tend to use Jupyter using its default interface/capabilities, which, in my opinion, can be significantly improved to provide a richer experience.

Therefore, in this article, I will present 5 cool Jupyter hacks that you probably never knew even existed.

These will allow you to unlock new levels of productivity and creativity with this powerful tool.

Let’s begin 🚀!

Often when we load a DataFrame in Jupyter, we preview it by printing. This is shown below:

However, it hardly tells anything about what’s inside this data.

As a result, one has to dig deeper by analyzing it, which involves simple yet repetitive code.

Instead, use Jupyter-DataTables. You can install it as follows:

To use it, run the following code in Jupyter:

It supercharges the default preview of a DataFrame with many useful features.

As a result, whenever you print a DataFrame, it will appear much more elegant as shown below.

This richer preview provides sorting, filtering, exporting, and pagination operations along with column distribution and data types

Not all data you get is labeled beforehand.

Thus, typically with unlabeled data, one may have to spend some time annotating/labeling it.

Rather than previewing the files externally and labeling them or building a complex annotation pipeline, you can annotate in just a few lines of code using 𝐢𝐩𝐲𝐚𝐧𝐧𝐨𝐭𝐚𝐭𝐞.

It provides a Jupyter widget specifically for data annotation.

Run the following commands to install it:

Data annotation becomes easier by clicking buttons. Thus, ipyannotate allows you to attach data labels to buttons.

Consider we have some images of cats and dogs (unlabeled). We can create an annotation pipeline as follows:

As shown above, you can annotate your data by simply clicking the corresponding button.

What’s more, you can also retrieve the labels and use them for your data pipeline as required.

While working in Jupyter, it is common to forget the parameters of a function and visit the official docs (or StackOverflow).

However, you can view the documentation in the notebook itself.

Pressing 𝐒𝐡𝐢𝐟𝐭-𝐓𝐚𝐛 opens the documentation panel. This is extremely useful and saves time as one does not have to open the official docs every single time.

A demo is shown below:

This feature also works for your custom functions.

After running some code in a Jupyter cell, we often navigate away to do some other work in the meantime.

Here, one has to repeatedly get back to the Jupyter tab to check whether the cell has been executed or not.

To avoid this, you can use the %%𝐧𝐨𝐭𝐢𝐟𝐲 magic command from the 𝐣𝐮𝐩𝐲𝐭𝐞𝐫𝐧𝐨𝐭𝐢𝐟𝐲 extension.

As the name suggests, it notifies the user upon completion (both successful and unsuccessful) of a Jupyter cell via a browser notification.

To install it, run the following command:

Next, load the extension:

And done!

Now, whenever you want to get notified, enter the following magic command at the top of the cell:

Whenever the cell will finish its execution, you will receive the following notification:

Clicking on the notification will take you back to the Jupyter tab.

While using Jupyter, we typically print many details to track the code’s progress.

However, it gets frustrating when the output panel has accumulated a bunch of details, but we are only interested in the most recent output.

Moreover, scrolling to the bottom of the output each time can be annoying too.

To clear the output of the cell, you can use the 𝗰𝗹𝗲𝗮𝗿_𝗼𝘂𝘁𝗽𝘂𝘁 method from the 𝗜𝗣𝘆𝘁𝗵𝗼𝗻 package.

IPython comes pre-installed with Python, so no installation is required.

You can import the method as follows:

When invoked, it will remove the current output of the cell, after which you can print the latest details.

A demo is shown below:

As demonstrated above, we only see the latest output in the cell. The previous outputs are being erased.

Although the above-mentioned tips will significantly enrich your Jupyter experience, there are still many things that I struggle to do with Jupyter.

For instance, Jupyter sucks when it comes to collaboration. As it runs locally, there is no way to embed real-time collaboration capabilities in Jupyter where teams can work together, add comments, track progress, etc.

What’s more, sharing is equally painful. If I ever have to share my notebook with someone, the only way to do that is by emailing them or hosting it online, on GitHub, for instance, and sharing the link.

Lastly, many data science tasks are not just limited to Python. They equally involve SQL, which is largely used to interact with organizational databases.

However, integrating SQL in Jupyter is feasible but a tedious process.

Solution

Frustrated with these limitations, I started looking for alternatives, and I am glad I discovered Deepnote.

Without having to learn anything new about how to use it, it took away all the limitations of Jupyter in a snap and has consistently offered me an enriching Jupyter-like experience.

Sharing, collaborating, using SQL, creating charts without any code, connecting to a database, etc., everything is seamlessly integrated into Deepnote.

While I understand that Jupyter tends to offer a generalized experience for all Python users, it miserably fails to address all the pain points of data scientists, especially those working in teams.

Deepnote, in my opinion, is a supercharged version of Jupyter for all data-driven projects, and you should definitely check it out.

With this, we come to the end of this blog.

Congratulations on learning a few incredible hacks for Jupyter notebook. I am sure these tips will level up your python programming productivity.

Also, I would love to know what are your favorite hacks while using Jupyter notebook.

As always, thanks for reading!

FOLLOW US ON GOOGLE NEWS

Read original article here

Denial of responsibility! Techno Blender is an automatic aggregator of the all world’s media. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – admin@technoblender.com. The content will be deleted within 24 hours.
Ai Newsartificial intelligenceAviChawlaexistedHacksJupyterknewmachine learningMAR
Comments (0)
Add Comment