11 Python libraries that are not commonly used but are very helpful for development, and 11 python libraries for development
Recently, more and more data scientists have started using Python, even though they have benefited a lot from libraries such as pandas, scikit-learn, and numpy, however, they may have missed some Python libraries that may be older but also helpful.
In this blog, I will recommend some little-known libraries. Even if you are a Python expert, you should take a look. One or two of these libraries may have never been seen before.
1) Delores
Dolorean is a cool date/time library. In addition to the nice name, it is also the most comfortable date/time modification library I have ever used. It is a bit like a javascript moment library, and will laugh every time I import it. The documentation is also great. In addition to technical guidance, they also reference countless contents of "Back to the Future" (to enrich the documentation ).
from delorean import DeloreanEST = "US/Eastern"d = Delorean(timezone=EST)
2) prettytable
This package is stored on GoogleCode, so you may have never heard of it. Google Code is now as desolate as Siberia.
Although it has been moved to an ice-and-snow, deserted place, prettytable is still the best structured output library, which can build good output in terminals or browsers. Therefore, if you are using a new IPython Notebook plug-in, we recommend 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", 87])table.add_row(["Rabbit of Caerbannog", 110])table.add_row(["cat", -1])table.add_row(["platypus", 23])table.add_row(["dolphin", 63])table.add_row(["albatross", 44])table.sort_key("ferocity")table.reversesort = True+----------------------+----------+| animal | ferocity |+----------------------+----------+| Rabbit of Caerbannog | 110 || wolverine | 100 || grizzly | 87 || dolphin | 63 || albatross | 44 || platypus | 23 || cat | -1 |+----------------------+----------+
3) snowballstemmer
I installed snowballstemmer in the first place because I thought the name was so cool. But it is indeed a small package. Snowballstemmer uses the porter stemmer algorithm to extract the word stem in 15 languages.
From snowballstemmer import EnglishStemmer, SpanishStemmer
EnglishStemmer (). stemWord ("Gregory ")
# Gregori
SpanishStemmer (). stemWord ("amarillo ")
# Amarill
4) wget
Remember every time you write a web crawler for a specific target? In the future, we can use other methods, that is, wget. Do you want to download all pages recursively? Want to capture each graph on the page? Do you want to avoid cookie tracing? Wget can give you everything you want.
In the movies of Mark zagberger
All the public directories here are public starting from Kiran (dormitory name) and allow directory insertion in the Apache system. So you can use a wget file to download images from all the photo libraries of Kiran. Easy!
This page has all the questions you want to ask about this library, and it is easy to use.
import wgetwget.download("<a href="http://www.cnn.com/">http://www.cnn.com/</a>")# 100% [............................................................................] 280385 / 280385
Users of linux and osx will also use another option: from sh import wget. However, the Python wget module provides better parameter processing.
5) PyMC
I don't remember how I got the PyMC package. Scikit-learn seems to be the darling of everyone (it deserves it, it's so amazing), 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 still don't know what it does? I will tell you that PyMC is mainly used for Bayesian Theorem analysis. Its features are highlighted in the Bayesian Methods for Hackers of Cam David son-Pilon. It is also a Shining Diamond on many popular data science/python blogs, however, it has never been sought after like its scikit-learn.
6) sh
I cannot let you go without knowing the sh library. Sh is used to import shell commands to Python. It is very useful in bash, but in Python you may not be able to use it (that is, recursive 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) fuzzywu.pdf
This is the simplest library I have used in the top 10. (If you have 2 or 3 minutes, you can read this resource.) fuzzywu.pdf is a fuzzy string matching library, which is created by developers on SeatGeek.
Fuzzywuzzy implements the token rate of the string, and the token ratio matches many other modes. It can also be used to create feature vectors or match records of different databases.
from fuzzywuzzy import fuzzfuzz.ratio("Hit me with your best shot", "Hit me with your pet shark")# 85
8) progressbar
When you call the _ main _ loop, have you used a prompt like print "still going? You know, it feels very low. Do you want to find something to replace it? Why not use progressbar to grade your game?
As you think, progressbar works well for precise data. It provides a progressbar in text mode. But even a variable of inaccurate data, it is better to use it than to use those long scripts.
Alas, this is another victim of GoogleCode, which has not received much attention (the document has two spaces for indentation ). You can install pip install.
from progressbar import ProgressBarimport timepbar = ProgressBar(maxval=10)for i in range(1, 11): pbar.update(i) time.sleep(1)pbar.finish()# 60% |######################################################## |
9) colorama
When you use progressbar to print logs, why don't you add colors to them! In fact, when a major error occurs, it will give you a quick reminder.
Colorama is easy to use. Just write it into your script and add it to the text you want to print:
Colorama-red
10) uuid
For me, there are only a few tools really needed in programming: hash, key-Value Pair storage, and common unique identifiers. Uuid is a UUID package of Python. It implements UUID standards standard versions 1, 3, 4, and 5. It is really convenient to ensure uniqueness.
This may sound silly, but how many times do you want to add the only Promotion Code to the marketing (sales goods? Or add a unique ID number to the email recipient?
If you are worried about exhausting ids, you do not need to use them! UUID can generate atomic data.
import uuidprint uuid.uuid4()# e7bafa3d-274e-4b0a-b9cc-d898957b4b61
If you are a UUID, you may think so ~~~~~
11) bashplotlib
We recommend that you use bashplotlib as a library. It draws a bar chart and a scatter chart through standard input. Of course, you don't need to consider using it to replace ggplot or matplotlib as your drawing package every day, just try it as a novelty. But at least, you can use it to make your log files look better.
$ pip install bashplotlib$ scatter --file data/texas.txt --pch x