11 Python libraries that are not commonly used but are very helpful for development

Source: Internet
Author: User
Tags unique id
Recently, as more and more data scientists began to use Python, I could not help but think that although they benefited from the libraries of Pandas, Scikit-learn and NumPy, they might have missed some of the older but also helpful python libraries.

In this blog post, I will recommend to you some little-known libraries. Even if you're a Python master, you should look at one or two of these libraries that you've never seen before.
1) Delores

Dolorean is a cool date/time library. In addition to the good name, but also a I have used the most comfortable date/time to modify the library. It's a bit like JavaScript's moment library, and every time I import it I want to laugh. The documentation is also great, with the exception of technical guidance, and they cite countless content from back to the future (to enrich the documentation).

From DeLorean import deloreanest = "Us/eastern" D = DeLorean (Timezone=est)

2) prettytable

The bag was put on the googlecode, so you may not have heard of it. Googlecode is now as desolate as Siberia.

Even though it was banished to a frozen, desolate place, prettytable is still the best structured output library to build good output in a terminal or browser. Therefore, if you are using IPython notebook's new plugin, it is recommended that you use prettytable instead of __repr__ for HTML output.

From prettytable Import prettytabletable = prettytable (["Animal", "ferocity"]) Table.add_row (["Wolverine", 100]) Table.add_row (["Grizzly",] table.add_row (["Rabbit of Caerbannog", []) Table.add_row (["Cat",-1]) Table.add_row ([ "Platypus") Table.add_row (["Dolphin",]) Table.add_row (["Albatross",]) Table.sort_key ("ferocity") Table.reversesort = true+----------------------+----------+|  Animal  | ferocity |+----------------------+----------+| Rabbit of Caerbannog | | |  Wolverine | |  Grizzly |  |  Dolphin |  |  Albatross |  |  Platypus |  |   Cat   |-1 |+----------------------+----------+

3) Snowballstemmer

I was pretending to be snowballstemmer because I thought the name was cool. But it's really a small package. Snowballstemmer uses the Porter Stemmer algorithm to extract word stemming from 15 languages.

From Snowballstemmer import Englishstemmer, Spanishstemmer
Englishstemmer (). Stemword ("Gregory")
# Gregori
Spanishstemmer (). Stemword ("Amarillo")
# Amarill
4) wget

Do you remember that every time you write a web crawler for a specific goal? Later we can use other methods to complete, that is wget. Want to recursively download all pages? Want to crawl every picture on a page? Want to avoid cookie tracking? Wget can give you everything you want.

In Mark Zagerberg's movie, it says it himself.

Starting with Kirkland (bedroom name), all public directories are public, and directories are allowed to be inserted into the Apache system. So with a wget you can download all the pictures in Kirkland's photo gallery. Easy!

This page has all the questions you want to ask about this library, and it's easy to use.

Import wgetwget.download ("http://www.cnn.com/") # 100% [ ............................................................................] 280385/280385

Linux and OSX users will also use another option: from SH import wget. However, the Python wget module also has better parameter handling.
5) PYMC

I don't remember how I got the PYMC bag. Scikit-learn seems to be the darling of everyone (it deserves it, it's fantastic), but in my opinion, PYMC is more attractive.

From pymc.examples import disaster_modelfrom pymc Import mcmcm = MCMC (Disaster_model) m.sample (iter=10000, burn=1000, thin=10) [-----------------100%-----------------] 10000 of 10000 complete in 1.4 sec

You don't know what it is, do you? Let me tell you, PYMC is mainly used to do Bayesian theorem analysis. Its features are highlighted in Cam Davidson-pilon's Bayesian Methods for hackers, which is also a shining diamond on many popular data science/python blogs. But it has never been as fanatical as its peers, Scikit-learn.
6) SH

I can't let you go if you don't know the SH library. SH is used to import shell commands into Python. It's super useful in bash, but in Python you may not be able to use it (i.e. recursively search for files).

From SH import findfind ("/tmp")/tmp/foo/tmp/foo/file1.json/tmp/foo/file2.json/tmp/foo/file3.json/tmp/foo/bar/ File3.json

7) Fuzzywuzzy

This is the simplest library I've ever used to rank in the top ten. (If you have 2 or 3 minutes, you can read this resource), Fuzzywuzzy is a string fuzzy matching library, which is built by developers on the SeatGeek.

Fuzzywuzzy implements the similarity rate of the string, the token ratio and many other matching patterns. It can also be used to create feature vectors or to match records from different databases.

From Fuzzywuzzy import fuzzfuzz.ratio ("Hits me with your best shot", "hits me with your pet shark") # 85

8) ProgressBar

When you call the __main__ loop, you use the print "still going ..." Such a hint? You know, it's going to feel very low. Looking for something to replace it? Why not use ProgressBar to improve your game's grade?

As you can imagine, ProgressBar works well for precise data, and it provides a text-mode ProgressBar. But even if it is a change of imprecise data, it is better to use it than with those very long scripts.

Alas, this is another victim of Googlecode, which has not received much attention (the document has two spaces indented). Use pip install to install it.

From ProgressBar import Progressbarimport Timepbar = ProgressBar (maxval=10) for I in range (1, one): Pbar.update (i) Time.slee P (1) pbar.finish () # 60% |########################################################          |

9) Colorama

When you print the log with ProgressBar, why not add color to them! In fact, when there is a big mistake, it can give you a quick reminder.

Colorama is easy to use. Just write it in your script and add it to the text you want to print:

Colorama-red
) UUID

For me, there are only a few tools that are really needed in programming: hash, key-value pair storage, and universal unique identifier. The UUID is one of Python's UUID packages. It implements the 1,3,4,5 version of the UUID Standards standard. It's really convenient to make sure it's unique.

This may sound a little silly, but how many times do you want to add a unique promo code to the marketing (sales goods)? Or to add a unique ID number to an e-mail recipient?

If you're worried about running out of IDs, don't! The UUID can generate atomic data.

Import Uuidprint Uuid.uuid4 () # E7bafa3d-274e-4b0a-b9cc-d898957b4b61

If you're a UUID, you might think so ~~~~~
One) Bashplotlib

Do not face to introduce yourself, Bashplotlib is a library I created. It plots histogram and scatter plots with standard input. Of course, you don't have to think about using it instead of Ggplot or matplotlib as a package that you draw every day, just try it as a novelty. But at least, you can use it to make your log files look good.

$ pip Install bashplotlib$ scatter--file data/texas.txt--pch x

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.