国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

你可能沒聽過的11個Python庫

2019-11-14 17:06:51
字體:
來源:轉載
供稿:網友

  目前,網上已有成千上萬個Python包,但幾乎沒有人能夠全部知道它們。單單 PyPi上就有超過47000個包列表。

  現在,越來越多的數據科學家開始使用Python,雖然他們從 pandas, scikit-learn, numpy中獲得了不少好處,但我仍想向他們介紹一些年長且非常實用的Python庫。在本文中,我將列一些不太知名的庫,即使你是經驗豐富的Python的開發者,也值得過來一看。

  1) delorean

  Dolorean是一個非常酷的日期/時間庫。類似javaScript的moment,擁有非常完善的技術文檔。

1
2
3
from delorean import Delorean
EST = "US/Eastern"
d = Delorean(timezone=EST)

  2) PRettytable

  你可能從未聽過該庫,因為它托管在GoogleCode。prettytable主要用于在終端或瀏覽器端構建很好的輸出。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from prettytable import PrettyTable
table = 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

  好吧,我也是首次安裝該庫。這是一款非常瘦小的語言轉換庫,支持15種語言。

1
2
3
4
5
from snowballstemmer import EnglishStemmer, SpanishStemmer
EnglishStemmer().stemWord("Gregory")
# Gregori
SpanishStemmer().stemWord("amarillo")
# amarill

  4.wget

  你是否還記得,每一次都會因為某個目的而編寫網絡爬蟲工具,以后再也不用了,因為wget就足夠你使用了。wget是Python版的網絡爬蟲庫,簡單好用。

  備注:linux和osx用戶這樣用:from sh import wget。但是,wget模塊還有一個更好的argument handline。

  5.PyMC

  scikit-learn似乎是所有人的寵兒,但在我看來,PyMC更有魅力。PyMC主要用來做Bayesian分析。

1
2
3
4
5
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

  6.sh

  sh庫用來將shell命令作為函數導入到Python中。在bash中使用是非常實用的,但是在Python中不容易記住怎么使用(即遞歸搜索文件)。

1
2
3
4
5
6
7
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

  Fuzzywuzzy是一個可以對字符串進行模糊匹配的庫,大家有空可以去 查看源碼

1
2
3
from fuzzywuzzy import fuzz
fuzz.ratio("Hit me with your best shot", "Hit me with your pet shark")
# 85

  8.progressbar

  progressbar是一個進度條庫,該庫提供了一個文本模式的progressbar。

1
2
3
4
5
6
7
8
from progressbar import ProgressBar
import time
pbar = ProgressBar(maxval=10)
for i in range(1, 11):
    pbar.update(i)
    time.sleep(1)
pbar.finish()
# 60% |########################################################                                      |

  9.colorama

  colorama主要用來給文本添加各種顏色,并且非常簡單易用。

  10.uuid

  uuid是基于Python實現的UUID庫,它實現了UUID標注的1,3,4和5版本,在確保唯一性上真的非常方便。

1
2
3
import uuid
print uuid.uuid4()
# e7bafa3d-274e-4b0a-b9cc-d898957b4b61

  11.bashplotlib

  bashplotlib是一個繪圖庫,它允許你使用stdin繪制柱狀圖和散點圖等。

1
2
$ pip install bashplotlib
$ scatter --file <span id="0_nwp" style="width: auto; height: auto; float: none;"><a id="0_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=18&is_app=0&jk=c83d3b1ac10215a4&k=data&k0=data&kdi0=0&luki=4&n=10&p=baidu&q=06011078_cpr&rb=0&rs=1&seller_id=1&sid=a41502c11a3b3dc8&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1922429&u=http%3A%2F%2Fwww%2Eadmin10000%2Ecom%2Fdocument%2F5893%2Ehtml&urlid=0" target="_blank" mpid="0" style="text-decoration: none;"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">data</span></a></span>/texas.txt --pch x

  英文原文: 11 Python Libraries You Might Not Know


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 冀州市| 娄烦县| 涟源市| 凌云县| 青海省| 额济纳旗| 班玛县| 孝义市| 通许县| 和田县| 两当县| 阿图什市| 邵东县| 宿迁市| 绩溪县| 桦甸市| 昔阳县| 乌鲁木齐县| 舒兰市| 九龙县| 海南省| 吴江市| 宜兰县| 新建县| 南木林县| 邵武市| 天柱县| 阳泉市| 安徽省| 丰都县| 平塘县| 云阳县| 浮梁县| 花莲市| 嘉鱼县| 垣曲县| 板桥市| 漳浦县| 东明县| 理塘县| 越西县|