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 useful Python libraries?

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

Share

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

This article focuses on "what are the useful Python libraries". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what are the good Python libraries.

1. Wget

Data extraction, especially from the network, is one of the important tasks of data scientists. Wget is a free tool for downloading non-interactive files from Web, which supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP agents. Because it is non-interactive, it can work in the background even if the user is not logged in. Therefore, she is very suitable for downloading all the images of a website or a page.

(project address: https://pypi.org/project/wget/)

Installation:

$pip install wget

Example:

Import wget url = 'http://www.futurecrew.com/skaven/song_files/mp3/razorback.mp3' filename = wget.download (url) 100% [...] 3841532 / 3841532 filename' razorback.mp3'

2. Pendulum

For those who need to use date and time in Python projects, Pendulum is a good project choice. It is a Python package used to simplify datetimes operations. It can completely replace the native class of Python.

(project address: https://github.com/sdispater/pendulum)

Installation:

$pip install pendulum

Example:

Import pendulum dt_toronto = pendulum.datetime (2012, 1, 1, tz='America/Toronto') dt_vancouver = pendulum.datetime (2012, 1, 1, tz='America/Vancouver') print (dt_vancouver.diff (dt_toronto). In_hours () 3

3. Imbalanced-learn

In fact, when the number of samples of each class is almost the same, the effect of the classification algorithm is the best, but in the actual project, most of the data sets are unbalanced. These data sets have an impact on the learning stage and subsequent prediction of machine learning algorithms. Imbalanced-learn is created to solve this kind of problems. It is compatible with scikit-learn and is a part of the scikit-learn-contrib project. The next time you come across an unbalanced data set, consider it.

(project address: https://github.com/scikit-learn-contrib/imbalanced-learn)

Installation:

Pip install-U imbalanced-learn # or conda install-c conda-forge imbalanced-learn

4. FlashText

Cleaning up text data in a NLP task usually requires replacing or extracting keywords in a sentence. This type of operation is usually done with regular expressions, but it becomes troublesome if you search for thousands of keywords. Python's FlashText module is based on the FlashText algorithm, which provides a suitable alternative for this situation. The best part of FlashText is that the runtime is the same regardless of the number of search terms.

(project address: https://github.com/vi3k6i5/flashtext)

Installation:

$pip install flashtext

Example:

From flashtext import KeywordProcessor keyword_processor = KeywordProcessor () # keyword_processor.add_keyword (,) keyword_processor.add_keyword ('Big Apple',' New York') keyword_processor.add_keyword ('Bay Area') keywords_found = keyword_processor.extract_keywords (' I love Big Apple and Bay Area.') Keywords_found ['New York',' Bay Area']

Keyword replacement:

Keyword_processor.add_keyword ('New Delhi',' NCR region') new_sentence = keyword_processor.replace_keywords ('I love Big Apple and new delhi.') New_sentence'I love New York and NCR region.'

5. Fuzzywuzzy

The name does sound strange, but fuzzywuzzy is a very useful library when it comes to character matching. Operations such as string matching degree, token matching degree and so on can be realized quickly. It can also easily match records stored in different databases.

(project address: https://github.com/seatgeek/fuzzywuzzy)

Installation:

$pip install fuzzywuzzy

Example:

From fuzzywuzzy import fuzz from fuzzywuzzy import process # Simple Ratio fuzz.ratio ("this is a test", "this is a test!") 97 # Partial Ratio fuzz.partial_ratio ("this is a test", "this is a test!") 100

6. PyFlux

Time series analysis is one of the most common problems in the field of machine learning. PyFlux is an open source Python library built to deal with time series problems. The library has a series of excellent modern time series models, including but not limited to ARIMA, GARCH and VAR models. In a word, PyFlux provides an efficient method for time series modeling. It's worth a try.

(project address: https://github.com/RJT1990/pyflux)

Installation:

Pip install pyflux

7. Ipyvolume

Result communication is an important aspect of data science, and visualization is a great advantage. IPyvolume is a Python library that is used to visualize three-dimensional graphics (such as three-dimensional drawings, etc.) in Jupyter notebooks. Unfortunately, it is still in the testing stage.

(project address: https://github.com/maartenbreddels/ipyvolume)

Installation:

Using pip $pip install ipyvolume Conda/Anaconda $conda install-c conda-forge ipyvolume

Example:

8. Dash

Dash is an efficient Python framework for building Web applications. It is based on Flask, Plotly.js, and React.js, and combines modern UI elements (such as dropboxes, sliders, and graphics) with user analytical Python code without the need for Javascript. Dash is very suitable for building data visualization applications. These applications can then be rendered in a Web browser.

(project address: https://github.com/plotly/dash)

Installation:

Pip install dash==0.29.0 # The core dash backend pip install dash-html-components==0.13.2 # HTML components pip install dash-core-components==0.36.0 # Supercharged components pip install dash-table==3.1.3 # Interactive DataTable component (new!)

Example:

9. Bashplotlib

Bashplotlib is a Python package and command-line tool for generating basic drawings at the terminal, written in Python, and making it easy to visualize data when users can't access GUI.

Installation:

Pip install bashplotlib

Example:

Scatter-file data/texas.txt-pch.

Hist-file data/exp.txt

10. Colorama

Colorama is a Python module specially used to output color text on the console and command line. It can be used across platforms and works well under windows and linux. It uses standard ANSI escape codes for coloring and styling terminal output. (project address: https://github.com/tartley/colorama)

Installation:

Pip install colorama

Example:

Import colorama from colorama import Fore, Back Style colorama.init () # Set the color semi-permanently print (Fore.CYAN) print ("The Text will appear in cyan until it is reset") print (Style.RESET_ALL) # Colorize a single line and then reset print (Fore.RED + 'Colorize a single line in RED' + Style.RESET_ALL) # Colorize a single word in the output print (' You can also colorize a single word' + Back.GREEN + 'words' + Style.RESET_ALL +' can be highlighted') # Combine foreground and background Color print (Fore.BLUE + Back.WHITE) print ('Foreground Background, and styles can be combined') print ("=") print (Style.RESET_ALL) print ('Reset everything back to normal.')

The output is as follows:

At this point, I believe that you have a deeper understanding of "what are the good Python libraries?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue 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