Skip to content

Commit 27e8672

Browse files
committed
add translated 'Handy Python Libraries for Formatting and Cleaning Data'
1 parent db47aeb commit 27e8672

File tree

5 files changed

+112
-145
lines changed

5 files changed

+112
-145
lines changed

Python Weekly/Python Weekly Issue 258.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
这篇文章讨论了参数化学习和线性分类的基础知识。虽然简单,但是线性分类可以被看成更高级的机器学习算法基本构架模块,自然扩展到神经网络和卷积神经网络。
4343

44-
[使用Python和LLVM的,用于TensorFlow计算图形的JIT本地代码生成](http://blog.christianperone.com/2016/08/jit-native-code-generation-for-tensorflow-computation-graphs-using-python-and-llvm/)
44+
[使用Python和LLVM的,用于TensorFlow计算图形的JIT本地代码生成](http://blog.christianperone.com/2016/08/jit-native-code-generation-for-tensorflow-computation-graphs-using-python-and-llvm/) [中文版](../Science and Data Analysis/用于格式化和数据清理的便捷Python库.md)
4545

4646
[Python JIT来了](https://lwn.net/Articles/691070/)
4747

Science and Data Analysis/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@
4242
帅爆了,用科学方法,分析权力游戏中错综复杂的人物关系。本文只实验了第三卷,看过之后,可以用其他卷来重现该实验~
4343

4444
- [使用Python探索NFL选秀](使用Python探索NFL选秀.md)
45+
46+
- [用于格式化和数据清理的便捷Python库](./用于格式化和数据清理的便捷Python库.md)
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
原文:[Handy Python Libraries for Formatting and Cleaning Data](https://blog.modeanalytics.com/python-data-cleaning-libraries/)
2+
3+
---
4+
5+
真实世界是杂乱的,它的数据也是。那么凌乱,[最近的一项调查](http://visit.crowdflower.com/data-science-report.html)显示,数据科学家花费60%的时间在清理数据。不幸的是,他们中57%还觉得这是他们工作中最不愉快的方面。
6+
7+
清理数据可能是耗时的,但是很多工具已经出现,让这个重要的任务惬意一点。Python社区提供了众多库,用来让数据有序清晰,从具有风格的DataFrame到匿名数据集。
8+
9+
如果你发现什么有用的库,请告诉我们,我们一直在寻找更好的库,以添加到[Mode Python Notebooks](https://about.modeanalytics.com/python/)中。
10+
11+
![Scrub that Data](https://blog.modeanalytics.com/images/post-images/python-data-cleaning-libraries.png)
12+
13+
_太糟糕的清理对数据科学家而言就像对这个小男孩一样,并不好玩。_
14+
15+
## Dora
16+
17+
Dora是为探索性分析而生的;具体来说,是为了自动化它最痛苦的那部分,如特征选择和提取,可视化,以及,是哒,你猜到了,就是数据清理。清理功能包括:
18+
19+
* 读取缺失和比例值不佳的数据
20+
* 输入缺失值
21+
* 缩放输入变量的值
22+
23+
**创建者:** [Nathan Epstein](https://twitter.com/epstein_n)
24+
**何处了解更多:** <https://github.com/NathanEpstein/Dora>
25+
26+
## datacleaner
27+
28+
令人感到惊奇的datacleaner清理你的数据 —— 但只在它是以[pandas DataFrame](https://community.modeanalytics.com/python/tutorial/pandas-dataframe/)形式出现的时候。据创建者Randy Olson说:“datacleaner并不是魔术,它不会读取文本的无组织块,然后自动的为你解析。”
29+
30+
但是,它会丢弃具有缺失值的行,在逐列基础上用模或者中位数来替换缺失值,并且用数值等效来编码非数值变量。这个库相当的新,但是由于在Python中,DataFrame是分析的基础,因此值得一看。
31+
32+
**创建者:** [Randy Olson](https://twitter.com/randal_olson)
33+
**何处了解更多:** <https://github.com/rhiever/datacleaner>
34+
35+
## PrettyPandas
36+
37+
DataFrame是强大的,但是它不会生成你想要展示给你老板看的那种表格。PrettyPandas利用[pandas Style API](http://pandas.pydata.org/pandas-docs/stable/style.html)来转换DataFrame成值得展示的表单。创建摘要,添加样式,并格式化数字、列和行。额外的好处:健壮、易读的[文档](http://prettypandas.readthedocs.io/en/latest/)
38+
39+
**创建者:** [Henry Hammond](https://twitter.com/henryhammond92)
40+
**何处了解更多:** <https://github.com/HHammond/PrettyPandas>
41+
42+
## tabulate
43+
44+
tabulate让你只用一次函数调用,就可以打印小而美的表格。它让列按照十进制、数字格式和表头等等进行排列,对于让表单更易读,它是非常方便的。
45+
46+
其中一个最酷的功能是,能够以多种格式,例如HTML, PHP或者Markdown Extra,来输出数据,所以你可以继续在另一个工具或者语言中处理你的表单数据。
47+
48+
**创建者:** Sergey Astanin
49+
**何处了解更多:** <https://pypi.python.org/pypi/tabulate>
50+
51+
## scrubadub
52+
53+
在诸如医疗保健和金融的领域中,数据科学家经常需要匿名数据集。scrubadub从免费文本中移除了[个人身份信息 (PII)](https://en.wikipedia.org/wiki/Personally_identifiable_information),如:
54+
55+
* 姓名 (专有名词)
56+
* 电子邮件地址
57+
* 网址
58+
* 电话号码
59+
* 用户名/密码组合
60+
* Skype用户名
61+
* 社保号
62+
63+
该文档在显示你可能想要自定义scrubadub行为的方面(例如定义新的PII类型,或者排除某些PII类型)表现良好。
64+
65+
**创建者:** [Datascope Analytics](http://datascopeanalytics.com/)
66+
**何处了解更多:** <http://scrubadub.readthedocs.io/en/stable/index.html>
67+
68+
## Arrow
69+
70+
坦白说:在Python中处理日期和时间很痛苦。本地时区不能够被自动识别。要花几行令人不爽的代码来转换时区和时间戳。
71+
72+
Arrow旨在修复这些问题和插件功能上的缺陷,来帮助你用更少的代码和更少的导入来处理时间和日期。不像Python的标准库,Arrow默认意识到时区和UTC。你可以用一行代码来转换时区或者解析字符串。
73+
74+
**创建者:** [Chris Smith](https://twitter.com/crsmithdev)
75+
**何处了解更多:** <http://arrow.readthedocs.io/en/latest/>
76+
77+
## Beautifier
78+
79+
Beautifier的任务很简单:清理和美化URL和电子邮件地址。你可以通过域名和用户名来解析电子邮件;通过域名和参数(例如,UTM或者令牌)来解析URL。
80+
81+
**创建者:** [Sachin Philip Mathew](https://twitter.com/sachin_philip)
82+
**何处了解更多:** <https://github.com/sachinvettithanam/beautifier>
83+
84+
## ftfy
85+
86+
ftfy (为你修正文本)接收糟糕的Unicode,输出漂亮的Unicode。基本上,它修复了所欲的垃圾字符。`“quotesâ€\x9d`变成`"quotes"`; `ü`变成`ü`; `&lt;3`变成`<3`。如果每天都在处理文本,那么这个库,正如一个用户所说,是“一个方便的法宝。”
87+
88+
**创建者:** [Luminoso](http://www.luminoso.com/)
89+
**何处了解更多:** <https://github.com/LuminosoInsight/python-ftfy>
90+
91+
## 管理数据的更多资源
92+
93+
这里是几个我们最喜欢的关于改写/管理/清理数据的文章。
94+
95+
* [每一个数据科学家都应该知道的关于数据匿名化的事](https://github.com/krasch/presentations/blob/master/pydata_Berlin_2016.pdf) (Katharina Rasch)
96+
* [在Python中清理数据](https://data.library.utoronto.ca/cleaning-data-python) (University of Toronto Map & Data Library)
97+
* [用Python进行数据清理 - MoMA的艺术品收藏](https://www.dataquest.io/blog/data-cleaning-with-python/) (Dataquest)

raw/Handy Python Libraries for Formatting and Cleaning Data.md

Lines changed: 0 additions & 133 deletions
This file was deleted.

raw/Stupid Python Tricks Abusing Explicit Self.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,18 @@ One object throwing an error triggered improved logging on a completely differen
125125

126126
# 总结
127127

128-
When you define an instance method on a class, it creates a corresponding “bound” method on the object. This aliases to the unbound method on the class.
129-
If you define an instance method directly on the object, there’s no corresponding unbound method on the class.
130-
Modifying the unbound method will also change all existing bound methods.
131-
You can use this to dynamically modify classes.
132-
Don’t.
133-
No really, don’t.
128+
当你定义一个类上的实例方法时,它创建了该对象上的一个对应的“绑定”方法。这是类上的非绑定方法的别名。如果你直接在对象上定义实例方法,那么类上就没有对应的非绑定方法。
129+
130+
修改非绑定方法也会改变所有现有的绑定方法。你可以用它来动态修改类。
131+
132+
不要。
133+
134+
真的,不要。
134135

135136
# 进一步阅读
136137

137-
* [Python method objects](https://docs.python.org/3/tutorial/classes.html#method-objects)
138-
* [Prototyping in Javascript](http://javascriptissexy.com/javascript-prototype-in-plain-detailed-language/)
139-
* [Static, class, and abstract methods](https://julien.danjou.info/blog/2013/guide-python-static-class-abstract-methods) (also has an important note on how Py2 is a little more complicated)
140-
* [Callback hell](http://callbackhell.com/)
141-
* [A rebuttal to callback hell](http://thecodebarbarian.com/2015/03/20/callback-hell-is-a-myth)
138+
* [Python method对象](https://docs.python.org/3/tutorial/classes.html#method-objects)
139+
* [Javascript中的原型](http://javascriptissexy.com/javascript-prototype-in-plain-detailed-language/)
140+
* [静态、类和抽象方法](https://julien.danjou.info/blog/2013/guide-python-static-class-abstract-methods) (还有一个关于Py2是如何有点复杂的重要注解)
141+
* [回调地狱](http://callbackhell.com/)
142+
* [回调地狱的一个反证](http://thecodebarbarian.com/2015/03/20/callback-hell-is-a-myth)

0 commit comments

Comments
 (0)