11 Python library _python that are not commonly used but are very helpful to development

Source: Internet
Author: User
Tags documentation unique id uuid in python

More and more data scientists have been using Python recently, and I can't help but think that although they have benefited from the libraries of Pandas, Scikit-learn and NumPy, they may have missed some of the older but equally helpful python libraries.

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

Dolorean is a cool date/time library. In addition to the nice name, it's also the most enjoyable date/time modification library I've ever used. It's a bit like a JavaScript moment library, and every time I import it I want to laugh. The documentation is great, and in addition to technical guidance, they cite countless things to go back to the future (to enrich the documentation).

From DeLorean import DeLorean
EST = "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.

Despite being exiled to a place of ice and snow, prettytable is still the best structured output library that can build good output in a terminal or browser. Therefore, if you are using IPython notebook new plugins, it is recommended that you use prettytable instead of __repr__ for HTML output.

From prettytable import prettytable
table = prettytable (["Animal", "ferocity"])
Table.add_row (["Wolverine", ]) Table.add_row (["
Grizzly", "Table.add_row") Caerbannog (["
Rabbit of Table.add_row", the "]")
,-1]) Table.add_row (["Platypus",
])
table.add_row (["Dolphin",]) Table.add_row (["
Albatross", 44])
Table.sort_key ("ferocity")
Table.reversesort = True
+----------------------+----------+
|  Animal  | ferocity
| +----------------------+----------+
| Rabbit of Caerbannog | A |
|  Wolverine | |  Grizzly | |  Dolphin | |  Albatross | |  Platypus |
|   Cat   |-1 |
+----------------------+----------+

3) Snowballstemmer

I pretended to be snowballstemmer because I thought it was a cool name. But it is really a small bag. Snowballstemmer uses the Porter Stemmer algorithm to extract word stems from 15 languages.

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

Do you remember every time you wrote a web crawler for a particular target? Later we can do it in other ways, that is wget. Want to download all pages recursively? Want to grab each picture on the page? Want to avoid cookie tracking? Wget can give you everything you want.

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

Starting with Cochran (the name of the dorm), all of the public catalogs here are open and allow you to insert directories in the Apache system. So you can download all the pictures in Cochran's photo gallery with a wget. Easy!

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

Import wget
wget.download ("<a href=" http://www.cnn.com/">http://www.cnn.com/</a>")
# 100% [ ............................................................................] 280385/280385

Linux and OS X users will also use another option: from SH import wget. But 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 everyone's pet (it deserves it, it's fantastic), but in my opinion, PYMC is more attractive.

From pymc.examples import Disaster_model from
pymc import MCMC
M = 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's for? Let me tell you, PYMC is mainly used to do Bayes theorem analysis. Its features are highlighted in Cam Davidson-pilon's Bayesian Methods for hackers, which is also a shining diamond in 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 leave without knowing the SH library. SH is used to import shell commands into Python. It's super useful in bash, but you may not be able to use it in Python (that is, recursively searching for files).

From SH import find find
("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, 3 minutes, you can read this resource), Fuzzywuzzy is a string fuzzy matching library, which is built by the developers on the SeatGeek.

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

From Fuzzywuzzy import fuzz
fuzz.ratio ("Hit me with your best shot", "Hit 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, this is going to feel really low. Looking for something to replace it? Why not use ProgressBar to improve your game's grade?

As you can imagine, ProgressBar works well when it comes to accurate data, which provides a progressbar of text patterns. But even a variable, imprecise data, it's better to use it than a long script.

Alas, this is another victim of Googlecode, which has not received much attention (the document has two spaces indented). You can install it with the PIP install.

From ProgressBar import ProgressBar
import time
pbar = ProgressBar (maxval=10)
to I in range (1, one):
 Pbar.update (i)
 time.sleep (1)
pbar.finish ()
# 60% |################################################ ########          |

9) Colorama

When you use ProgressBar to print the log, why not add color to them! In fact, when there is a major error, it will be able to 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 a Python uuid package. It implements the 1,3,4,5 version of the UUID Standards standard. It's really handy to be sure of uniqueness.

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

If you're worried about running out of IDs, not at all! The UUID can generate atomic data.

Import UUID
print uuid.uuid4 ()
# E7bafa3d-274e-4b0a-b9cc-d898957b4b61

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

No face, Bashplotlib is a library I created. It draws the histogram and scatter chart by standard input. Of course, you don't have to consider using it instead of Ggplot or matplotlib as your daily drawing package, just try it as a novelty. But at the very least, you can use it to make your log files look better.

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

Related Article

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.