Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the Jupyter notebook plug-ins to improve Python productivity

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the Jupyter notebook plug-ins to improve Python productivity, which have a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to know about it.

1. Jupyter-resource-usage

Have you ever experienced a situation where Jupyter Notebook slows down or crashes due to memory problems? This often happens when we explore big data, which takes up a lot of memory, or the heavy modeling and computing process.

To control memory problems, we can use the jupyter-resource-usage extension to display memory usage in our Notebook. This extension is simple; all resources in your current laptop server and sub-server will be displayed in the upper-right corner. Let's try to install the extension.

Pip install jupyter-resource-usage

After you finish installing the package, try restarting Jupyter and accessing your Jupyter Notebook. The memory display should now be available in your laptop.

If you want to limit the resources allocated, you can use the various methods explained here to control them. The link is: https://github.com/jupyter-server/jupyter-resource-usage

2. Pyforest

Every time you work in a new environment or develop a new project, you must import all the required packages, but sometimes it is not pleasant to re-import all the packages. This is why pyforest was developed.

Pyforest extensions are popular python packages that are automatically imported from Bamboolib developers. This extension transforms your workflow into automatically importing such popular packages, such as pandas, numpy, sklearn, and so on. You can view the list here.

Let's try to install the pyforest extension.

Pip install-- upgrade pyforestpython-m pyforest install_extensions

After you have finished installing the package, you should restart Jupyter for automatic pyforest import.

Let's see if the extension has taken place.

As you can see from the figure above, I didn't import any seaborn or pandas packages, but I can use it automatically in my Jupyter Notebook. The pyforest extension automatically imports this package with popular abbreviations (seaborn for sns,pandas, pd, etc.).

You don't have to worry about memory allocation, because pyforest doesn't import all the packages at first, but imports the required packages when executing code that uses specific packages.

3. Jupyter theme

As the name implies, jupyter-themes is a Jupyter Notebook extension for changing themes. This extension also changes our drawings, pandas data boxes, and so on. Therefore, the theme change is not limited to the Jupyter Notebook background.

Let's try to install jupyter-themes. You can install the package using the following code.

Pip install jupyterthemes

After installation, first, let's use the following code from a command prompt to view the available topics.

Jt-l

There are nine themes for us to choose from by default. Let's try one of the themes, such as "chesterish".

Jt-t chesterish

To see the changes in Jupyter Notebook, you need to restart the server. After that, you will see a notebook similar to the following figure.

If you want to reset the theme to the default theme, you can use the following code to reset it.

Jt-r

You can still use jupyter-theme to do a lot of things, such as controlling color, cell width, hiding specific toolbars, and so on. You can read all the commands on their page.

4. Jupyter-notify

The jupyter-notify extension is a Jupyter Notebook extension that notifies us when our unit finishes running. This extension is useful when running a time-consuming modeling process or cleanup activity and you want to do something else while waiting.

First, we need to install the package using the following code.

Pip install jupyternotify

After installing this package, you need to load the notification in Jupyter Notebook by running the following magic command code.

% load_ext jupyternotify

The setup is ready; let's try running Notebook and get notified. For example, we will use the following code.

% notifyimport timetime.sleep (2) print ('Finish Trying Notifiy')

Using the magic command%% notify in the cell, we will be notified similar to the above when we finish running the code. If you want to include a specific message in the notification, you can add the message as in the following example.

% notify-m "Execution done" time.sleep (2) print ('Finish Trying Notifiy')

Adding the-m parameter after the magic command allows you to edit the message. This is helpful if you need to be notified of a specific message.

5. Watermark watermark

The watermark watermark extension is a magic command that allows us to print hardware, version, time, and more information through the Jupyter Notebook environment. It will be helpful if we need to get information quickly in the process of exploration.

To install the package, we need to use the following code

Pip install watermark

After installing the package, we can load the extension in our Notebook by running the following code.

% load_ext watermark

Let's try to extend in Jupyter Notebook. First, we can run the following code to get our hardware information.

% watermark

By default, the magic command% watermark provides us with hardware information. We can use watermarks to get a lot of information, such as the package version we imported in the Jupyter Notebook environment.

Thank you for reading this article carefully. I hope the article "what are the Jupyter notebook plug-ins to improve Python productivity" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report