提交 13079b9d 编写于 作者: W wizardforcel

2020-07-12 17:11:24

上级 0f4a34e7
......@@ -10,7 +10,7 @@
对于许多使用 Python 的数据分析人员和科学家来说,绝大多数工作将使用 Pandas 来完成。 这可能是因为最初的数据探索和准备往往花费最多的时间。 一些整个项目仅包含数据探索,没有机器学习组件。 数据科学家在此阶段花费了太多时间,以至于出现了永恒的传说 - *数据科学家花费了 80% 的时间来清理数据,另外 20% 的时间抱怨清理数据。*
尽管有大量的开放源代码和免费编程语言可用于数据探索,但目前该领域仅由两个参与者(Python 和 R)主导。这两种语言的语法差异很大,但都具有进行数据分析和机器处理的能力 学习。 受欢迎程度的一种度量是在受欢迎的 Q & A 站点 Stack Overflow( [https://insights.stackoverflow.com/trends](https://insights.stackoverflow.com/trends)上提出的问题数量:
尽管有大量的开放源代码和免费编程语言可用于数据探索,但目前该领域仅由两个参与者(Python 和 R)主导。这两种语言的语法差异很大,但都具有进行数据分析和机器处理的能力 学习。 受欢迎程度的一种度量是在受欢迎的 Q&A 站点 [Stack Overflow](https://insights.stackoverflow.com/trends) 上提出的问题数量:
![](img/00005.jpeg)
......@@ -54,11 +54,11 @@ Pandas 是用于 Python 编程语言的第三方软件包,在本书出版时
除了 Pandas,您还需要安装 matplotlib 2.0 版和 seaborn 0.8 版可视化库。 对 Pandas 的主要依赖是 NumPy 库,它构成了大多数流行的 Python 科学计算库的基础。
您可以通过多种方式来安装 Pandas 和计算机上提到的其余库,但是到目前为止,最简单的方法是安装 Anaconda 发行版。 它由 Continuum Analytics 创建,将所有流行的用于科学计算的库打包到一个可下载的文件中,该文件可在 Windows,Mac OSX 和 Linux 上使用。 访问下载页面以获取 Anaconda 发行版( [https://www.anaconda.com/download](https://www.anaconda.com/download/)
您可以通过多种方式来安装 Pandas 和计算机上提到的其余库,但是到目前为止,最简单的方法是安装 Anaconda 发行版。 它由 Continuum Analytics 创建,将所有流行的用于科学计算的库打包到一个可下载的文件中,该文件可在 Windows,Mac OSX 和 Linux 上使用。 访问[下载页面](https://www.anaconda.com/download)以获取 Anaconda 发行版
除了所有科学计算库之外,Anaconda 发行版还附带 Jupyter Notebook,这是一个基于浏览器的程序,可使用 Python 和许多其他语言进行开发。 本书的所有秘籍都是在 Jupyter 笔记本内部开发的,每一章的所有单个笔记本都可以使用。
无需使用 Anaconda 发行版就可以安装本书所需的所有库。 对于感兴趣的用户,请访问 pandas *安装*页面( [http://pandas.pydata.org/pandas-docs/stable/install.html](http://pandas.pydata.org/pandas-docs/stable/install.html)
无需使用 Anaconda 发行版就可以安装本书所需的所有库。 对于感兴趣的用户,请访问 [Pandas *安装*页面](http://pandas.pydata.org/pandas-docs/stable/install.html)
# 运行 Jupyter 笔记本
......@@ -101,7 +101,7 @@ Anaconda Navigator 是基于 GUI 的工具,可让您轻松查找 Anaconda 提
# 如何充分利用这本书
您可以采取几项措施来充分利用本书。 首先,也是最重要的是,您应该下载所有代码,这些代码将存储在 Jupyter Notebooks 中。 阅读每个秘籍时,请在笔记本中运行代码的每个步骤。 在运行代码时,请确保自己进行探索。 其次,在您的浏览器选项卡之一中打开 pandas 官方文档( [http://pandas.pydata.org/pandas-docs/stable/](http://pandas.pydata.org/pandas-docs/stable/)。 Pandas 文档是一个很好的资源,其中包含超过 1000 页的材料。 文档中有大多数 Pandas 操作的示例,它们通常会*直接链接到*“另见”部分。 虽然涵盖了大多数操作的基础知识,但它提供了一些琐碎的示例和伪造的数据,这些伪造的数据并不能反映您在分析现实世界中的数据集时可能遇到的情况。
您可以采取几项措施来充分利用本书。 首先,也是最重要的是,您应该下载所有代码,这些代码将存储在 Jupyter Notebooks 中。 阅读每个秘籍时,请在笔记本中运行代码的每个步骤。 在运行代码时,请确保自己进行探索。 其次,在您的浏览器选项卡之一中打开 [Pandas 官方文档](http://pandas.pydata.org/pandas-docs/stable/)。 Pandas 文档是一个很好的资源,其中包含超过 1000 页的材料。 文档中有大多数 Pandas 操作的示例,它们通常会*直接链接到*“另见”部分。 虽然涵盖了大多数操作的基础知识,但它提供了一些琐碎的示例和伪造的数据,这些伪造的数据并不能反映您在分析现实世界中的数据集时可能遇到的情况。
# 约定
......@@ -156,7 +156,7 @@ Tips and tricks appear like this.Warnings or important notes appear in a box lik
# 数据集说明
本书共使用了大约十二个数据集。 完成秘籍中的步骤时,在每个数据集上具有背景信息可能会非常有帮助。 可以在 [https://github.com/PacktPublishing/Pandas-Cookbook](https://github.com/PacktPublishing/Pandas-Cookbook)`dataset_descriptions` Jupyter Notebook 中找到每个数据集的详细说明。 对于每个数据存储,将有一个列列表,有关每个列的信息以及有关如何获取数据的注释。
本书共使用了大约十二个数据集。 完成秘籍中的步骤时,在每个数据集上具有背景信息可能会非常有帮助。 可以在 [PacktPublishing/Pandas-Cookbook](https://github.com/PacktPublishing/Pandas-Cookbook)`dataset_descriptions` Jupyter Notebook 中找到每个数据集的详细说明。 对于每个数据存储,将有一个列列表,有关每个列的信息以及有关如何获取数据的注释。
# 栏目
......
......@@ -62,7 +62,7 @@ The Python standard library contains the `csv` module, which can be used to pars
# 另见
* Pandas`read_csv`函数的官方文档( [http://bit.ly/2vtJQ9A](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html)
* [Pandas `read_csv`函数的官方文档](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html)
# 访问主要的数据帧组件
......@@ -155,8 +155,8 @@ array(['color', 'director_name', 'num_critic_for_reviews',
# 另见
* 的 Pandas 官方文档 *索引和选择数据*[http://bit.ly/2vm8f12](https://pandas.pydata.org/pandas-docs/stable/indexing.html)
* *Pandas 设计与开发的内幕*Pandas 作者 Wes McKinney( [http://bit.ly/2u4YVLi](http://wesmckinney.com/blog/nycpython-1102012-a-look-inside-pandas-design-and-development/) )的幻灯片
* [Pandas *索引和选择数据*的官方文档](https://pandas.pydata.org/pandas-docs/stable/indexing.html)
* [*Pandas 设计与开发的内幕*作者 Wes McKinney 的幻灯片](http://wesmckinney.com/blog/nycpython-1102012-a-look-inside-pandas-design-and-development/)
# 了解数据类型
......@@ -222,8 +222,8 @@ object 12
# 另见
* Pandas `dtypes`的官方文档( [http://bit.ly/2vxe8ZI](http://pandas.pydata.org/pandas-docs/stable/basics.html#dtypes)
* NumPy 数据类型官方文档( [http://bit.ly/2wq0qEH](https://docs.scipy.org/doc/numpy/user/basics.types.html)
* [Pandas `dtypes`的官方文档](http://pandas.pydata.org/pandas-docs/stable/basics.html#dtypes)
* [NumPy 数据类型官方文档](https://docs.scipy.org/doc/numpy/user/basics.types.html)
# 选择单列数据作为系列
......@@ -288,7 +288,7 @@ Series 的视觉输出风格比数据帧少。 它代表一列数据。 连同
# 另见
* 要了解 Python 对象如何获得使用索引运算符的能力,请参见`__getitem__`特殊方法( [http://bit.ly/2u5ISN6](https://docs.python.org/3/reference/datamodel.html#object.__getitem__) )上的 Python 文档
* 要了解 Python 对象如何获得使用索引运算符的能力,请参见 Python 文档中的[`__getitem__`特殊方法](https://docs.python.org/3/reference/datamodel.html#object.__getitem__)
* 请参阅第 2 章,“基本数据帧操作”的“选择多个数据帧列”秘籍
# 调用序列方法
......@@ -575,7 +575,7 @@ False
set([2,3])
```
访问教程要点( [http://bit.ly/2u5g5Io](https://www.tutorialspoint.com/python/python_basic_operators.htm),以查看所有基本 Python 运算符的表。 并非对每个对象都实现所有运算符。 这些示例在使用运算符时都会产生错误:
访问 [TutorialsPoint](https://www.tutorialspoint.com/python/python_basic_operators.htm),以查看所有基本 Python 运算符的表。 并非对每个对象都实现所有运算符。 这些示例在使用运算符时都会产生错误:
```py
>>> [1, 2, 3] - 3
......@@ -706,8 +706,8 @@ Name: director_name, Length: 4916, dtype: bool
# 另见
* 有关运算符的 Python 官方文档( [http://bit.ly/2wpOId8](https://docs.python.org/3/library/operator.html)
* 有关数据模型的 Python 官方文档( [http://bit.ly/2v0LrDd](https://docs.python.org/3/reference/datamodel.html)
* [Python 运算符官方文档](https://docs.python.org/3/library/operator.html)
* [Python 数据模型官方文档](https://docs.python.org/3/reference/datamodel.html)
# 连锁序列方法在一起
......@@ -862,7 +862,7 @@ DataFrame 的索引为每行提供一个标签。 如果在创建数据帧时未
# 另见
* Pandas 的`RangeIndex`官方文档( [http://bit.ly/2hs6DNL](https://pandas.pydata.org/pandas-docs/stable/advanced.html#int64index-and-rangeindex)
* [Pandas `RangeIndex`官方文档](https://pandas.pydata.org/pandas-docs/stable/advanced.html#int64index-and-rangeindex)
# 重命名行和列名称
......
......@@ -166,7 +166,7 @@ Regular expressions are character sequences that represent search patterns to be
# 另见
* 请参阅第 1 章,“Pandas 基础”,“了解数据类型”。
* 很少使用的`select`方法还可以根据列名选择它们。( [http://bit.ly/2fchzhu](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.select.html)
* [很少使用的`select`方法还可以根据列名选择它们](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.select.html)
# 明智地订购列名称
......@@ -583,7 +583,7 @@ True
# 另见
* 每个计算机科学家都应该了解有关浮点运算的知识( [http://bit.ly/2vmYZKi](http://bit.ly/2vmYZKi)
* [每个计算机科学家都应该了解有关浮点运算的知识](http://bit.ly/2vmYZKi)
# 比较缺失值
......@@ -810,7 +810,7 @@ UGDS_UNKN 0.01430
# 另见
* Pandas `cumsum`的官方文档( [http://bit.ly/2v3B6EZ](http://bit.ly/2v3B6EZ)
* [Pandas `cumsum`的官方文档](http://bit.ly/2v3B6EZ)
# 确定大学校园的多样性
......@@ -985,4 +985,4 @@ True
# 另见
* 美国新闻校园种族多样性 2015-2016( [http://bit.ly/2vmDhWC](http://bit.ly/2vmDhWC)
\ No newline at end of file
* [美国新闻校园种族多样性 2015-2016](http://bit.ly/2vmDhWC)
\ No newline at end of file
......@@ -113,7 +113,7 @@ Internally, pandas stores columns of the same data type together in blocks. For
# 另见
* NumPy 数据层次结构文档( [http://bit.ly/2yqsg7p](http://bit.ly/2yqsg7p)
* [NumPy 数据层次结构文档](http://bit.ly/2yqsg7p)
# 通过更改数据类型减少内存
......@@ -315,7 +315,7 @@ The equivalence of a string and the outright pandas or NumPy object occurs elsew
# 另见
* Pandas 有关数据类型的官方文档( [http://bit.ly/2vxe8ZI](http://pandas.pydata.org/pandas-docs/stable/basics.html#dtypes)
* [Pandas 数据类型的官方文档](http://pandas.pydata.org/pandas-docs/stable/basics.html#dtypes)
# 从最大的中选择最小的
......@@ -489,7 +489,7 @@ The equivalence of a string and the outright pandas or NumPy object occurs elsew
# 更多
如果查看`nlargest`文档,则会看到`keep` 参数具有三个可能的值,`first``last``False`。 据我对其他 Pandas 方法的了解,`keep=False`应该允许所有纽带保留在结果中。 不幸的是,Pandas 在尝试执行此操作时会引发错误。 我在 GitHub 上与 pandas 开发团队创建了一个问题,以进行此增强( [http://bit.ly/2fGrCMa](https://github.com/pandas-dev/pandas/issues/16818)
如果查看`nlargest`文档,则会看到`keep` 参数具有三个可能的值,`first``last``False`。 据我对其他 Pandas 方法的了解,`keep=False`应该允许所有纽带保留在结果中。 不幸的是,Pandas 在尝试执行此操作时会引发错误。 [我在 GitHub 上与 pandas 开发团队创建了一个问题](https://github.com/pandas-dev/pandas/issues/16818),以进行此改进
# 计算追踪止损单价格
......@@ -591,4 +591,4 @@ Name: Close, dtype: float64
# 另见
* Pandas 的另外两种累积方法的官方文档,`cumsum`[http://bit.ly/2v3B6EZ](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.cumsum.html) )和`cumprod`[http://bit.ly/2uHBWGt](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.cumprod.html)
\ No newline at end of file
* Pandas 的另外两种累积方法的官方文档,[`cumsum`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.cumsum.html)[`cumprod`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.cumprod.html)
\ No newline at end of file
......@@ -146,7 +146,7 @@ Series([], Name: CITY, dtype: object)
# 另见
* Pandas 有关索引的官方文档( [http://bit.ly/2fdtZWu](http://pandas.pydata.org/pandas-docs/stable/indexing.html)
* [Pandas 索引的官方文档](http://pandas.pydata.org/pandas-docs/stable/indexing.html)
# 选择数据帧行
......
......@@ -212,7 +212,7 @@ Many objects in Python have boolean representation. For instance, all integers e
# 另见
* Python 运算符优先级( [http://bit.ly/2vxuqSn](https://docs.python.org/3/reference/expressions.html#operator-precedence)
* [Python 运算符优先级](https://docs.python.org/3/reference/expressions.html#operator-precedence)
# 使用布尔索引进行过滤
......@@ -301,8 +301,8 @@ True
# 另见
* 有关“布尔索引”( [http://bit.ly/2v1xK77](http://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing) )的 Pandas 官方文档
* 检查 Python 对象的真伪( [http://bit.ly/2vn8WXX](https://docs.python.org/3/library/stdtypes.html#truth)
* [Pandas “布尔索引”官方文档](http://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing)
* [检查 Python 对象的真实性](https://docs.python.org/3/library/stdtypes.html#truth)
# 使用索引选择复制布尔索引
......@@ -486,7 +486,7 @@ Name: Stanford University, dtype: object
# 另见
* *二分搜索算法*[http://bit.ly/2wbMq20](https://en.wikipedia.org/wiki/Binary_search_algorithm)
* [二分搜索算法](https://en.wikipedia.org/wiki/Binary_search_algorithm)
# 了解股票价格
......@@ -731,11 +731,11 @@ WHERE
# 另见
* Pandas `isin`[http://bit.ly/2v1GPfQ](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.isin.html) )和`between`[http://bit.ly/2wq9YPF](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.between.html)序列方法的官方文档
* Pandas [`isin`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.isin.html)[`between`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.between.html)序列方法的官方文档
* 请参阅第 9 章,“合并 Pandas 对象”中的“连接到 SQL 数据库”秘籍。
* W3 学校对 SQL 的基本介绍( [http://bit.ly/2hsq8Wp](https://www.w3schools.com/sql/DEfaULT.asP)
* SQL IN 运算符( [http://bit.ly/2v3H7Bg](https://www.w3schools.com/sql/sql_in.asp)
* SQL BETWEEN 运算符( [http://bit.ly/2vn5UTP](https://www.w3schools.com/sql/sql_between.asp)
* [W3Schools 的 SQL 基本介绍](https://www.w3schools.com/sql/DEfaULT.asp)
* [SQL `IN`运算符](https://www.w3schools.com/sql/sql_in.asp)
* [SQL `BETWEEN`运算符](https://www.w3schools.com/sql/sql_between.asp)
# 确定股票市场收益的正常性
......@@ -842,7 +842,7 @@ Name: Close, dtype: float64
# 另见
* Pandas`pct_change`序列方法的官方文档( [http://bit.ly/2wcjmqT](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.pct_change.html)
* [Pandas `pct_change`序列方法的官方文档](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.pct_change.html)
# 使用查询方法提高布尔索引的可读性
......@@ -901,7 +901,7 @@ The `query` DataFrame method is experimental and not as capable as boolean index
# 另见
* 关于`query`方法的 Pandas 官方文档( [http://bit.ly/2vnlwXk](http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-query)
* [Pandas `query`方法的官方文档](http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-query)
# 使用 where 方法保存系列
......@@ -1037,7 +1037,7 @@ True
# 另见
* 有关`where`方法的 Pandas 官方文档( [http://bit.ly/2vmW2cv](http://bit.ly/2vmW2cv)
* [Pandas `where`方法的官方文档](http://bit.ly/2vmW2cv)
# 屏蔽数据帧行
......@@ -1140,8 +1140,8 @@ from pandas.testing import assert_frame_equal
# 另见
* Pandas 关于`assert_frame_equal`的官方文档( [http://bit.ly/2u5H5Yl](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.testing.assert_frame_equal.html)
* `assert`语句的 Python 官方文档( [http://bit.ly/2v1YKmY](https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement)
* [Pandas `assert_frame_equal`的官方文档](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.testing.assert_frame_equal.html)
* [Python `assert`语句的官方文档](https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement)
# 使用布尔值,整数位置和标签进行选择
......
......@@ -109,7 +109,7 @@ used for its implementation, and object access becomes much slower.
# 另见
* Pandas`Index`的官方文档( [http://bit.ly/2upfgtr](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Index.html)
* [Pandas `Index`的官方文档](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Index.html)
# 生产笛卡尔积
......@@ -767,7 +767,7 @@ array(['California Institute of Technology',
# 另见
* Pandas 数据帧*样式*的官方文档( [http://bit.ly/2hsZkVK](https://pandas.pydata.org/pandas-docs/stable/style.html)
* [Pandas 数据帧*样式*的官方文档](https://pandas.pydata.org/pandas-docs/stable/style.html)
# 使用方法链接复制 idxmax
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册