{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Python编程环境"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Guido Van Rossum和版本 "
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### [Guido](https://gvanrossum.github.io/)是[Python](https://www.python.org/)的作者\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"在下面的访谈中,[Peter Norvig](https://en.wikipedia.org/wiki/Peter_Norvig)也没有念对他的名字,Guido的主页有它的荷兰语发音。\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
">他在[stackoverflow](https://stackoverflow.com/users/818274/guido-van-rossum)和[github](https://github.com/gvanrossum)上非常活跃。他的[twitter](https://twitter.com/gvanrossum)更新很勤。\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"- 抛开Python的[前世、今生和未来](http://bazhou.blob.core.windows.net/learning/mpp/python-past-present-and-future-with-guido-van-rossum.mp3) 第一个现实问题是:版本。\n",
"- Python有两个版本:2和3。\n",
"- 我们用版本3,再确切些,3.6.5。\n",
"- 版本问题会引起很大的麻烦,这门课的解决方法是Docker。"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### 我们使用Python[3.6](https://docs.python.org/3/whatsnew/3.6.html)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Shell Script REPL"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"- Shell 命令输入处"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"- Script 命令"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"- REPL Read-Evaluate-Print-Loop"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### 挑战:获得这门课程的词汇表"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"- 17段视频的字幕文件"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"- 输入数据[例子](http://bazhou.blob.core.windows.net/learning/mpp/msxpy/16_253_6.2-wCnbczfN91s.txt)\n",
"\n",
"4\n",
"\n",
"00:00:14,010 --> 00:00:19,009\n",
"\n",
"In practice, you'll be working with data of\n",
"different types: numerical values, strings,\n",
"\n",
"5\n",
"\n",
"00:00:19,009 --> 00:00:21,279\n",
"\n",
"booleans and so on.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"- 用管道连接脚本"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"```bash\n",
"cat *.txt|./clean.sh #清洗字幕文件,分词\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"```bash\n",
"cat *.txt|./clean.sh|sort|uniq #去掉重复,排序\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"```bash\n",
"cat *.txt|./clean.sh|sort|uniq|wc #统计单词数\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"- 清洗字幕脚本 [clean.sh](http://bazhou.blob.core.windows.net/learning/mpp/msxpy/clean.sh)\n",
"\n",
"```bash\n",
"#!/bin/sh\n",
"tr '[:blank:]' '\\n'|tr '[:upper:]' '[:lower:]'|tr -d '\\r'|grep -vE \"'\"|grep -vE \"\\.\"|tr -d '[:punct:]'|grep -vE \"^[^a-zA-Z].*\"|grep -vE \".*[0-9].*\"\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Jupyter\n",
"\n",
"[命名](https://news.ycombinator.com/item?id=16978364)\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Jupyter\n",
"\n",
">Jupyter像Shell一样,在cell里编辑,在cell里运行,循环往复\n",
"\n",
"- R 编辑cell,Enter\n",
"- E 运行cell,Shift+Enter\n",
"- P 打印cell\n",
"- L 下个cell\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"hello world\n"
]
}
],
"source": [
"print(\"hello world\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# 变量和数据类型"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## 数字及其运算"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"- 计算身高体重指数\n",
"- BMI(Body Mass Index) 公式\n",
" \\begin{equation}BMI = \\frac{weight}{height^{2}}\\end{equation}"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"height = 1.79 # 身高1米79"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"weight = 68.7 # 体重68.7公斤"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"bmi = weight / height ** 2"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"21.44127836209856"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bmi"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"- 数据类型\n",
"- float/int\n",
"- str\n",
"- bool"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"float"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(bmi)"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"int"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(2)"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"str"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(\"hello world\")"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"bool"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(True)"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2 + True # 数据类型转换"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"ename": "TypeError",
"evalue": "must be str, not int",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;34m\"hello\"\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m2\u001b[0m \u001b[0;31m# 运算是有类型的\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: must be str, not int"
]
}
],
"source": [
"\"hello\" + 2 # 运算是有类型的 "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"\"hello\" + \"world\" # + : 字符串连接"
]
},
{
"cell_type": "code",
"execution_count": 83,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"24.4"
]
},
"execution_count": 83,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2 + 22.4 # + : 加法; 数据类型转换 int → float "
]
},
{
"cell_type": "code",
"execution_count": 84,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"9"
]
},
"execution_count": 84,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"77 % 17 # 取模"
]
},
{
"cell_type": "code",
"execution_count": 85,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"4"
]
},
"execution_count": 85,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"77 // 17 # 求商"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 字符串及其运算\n",
">字符串是字符的集合"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"```python\n",
"he = \"他\"\n",
"didnt = \"没\"\n",
"verb = \"上\"\n",
"obj = \"上海的车\"\n",
"# 用字符串组成另一个字符串\n",
"he + didnt + verb * 3 + obj\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 86,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"'他没上上上上海的车'"
]
},
"execution_count": 86,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"he = \"他\"\n",
"didnt = \"没\"\n",
"verb = \"上\"\n",
"obj = \"上海的车\"\n",
"# 用字符串组成另一个字符串\n",
"he + didnt + verb * 3 + obj"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"- 如果 + * 代表往字符串集合中增加元素\n",
"- 那么 - / 运算是取字符串集合的子集?"
]
},
{
"cell_type": "code",
"execution_count": 87,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"ename": "TypeError",
"evalue": "unsupported operand type(s) for -: 'str' and 'str'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mobj\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0mverb\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for -: 'str' and 'str'"
]
}
],
"source": [
"obj - verb"
]
},
{
"cell_type": "code",
"execution_count": 88,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"ename": "TypeError",
"evalue": "unsupported operand type(s) for /: 'str' and 'str'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mobj\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0mverb\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for /: 'str' and 'str'"
]
}
],
"source": [
"obj / verb"
]
},
{
"cell_type": "code",
"execution_count": 89,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"'海'"
]
},
"execution_count": 89,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"obj[1]"
]
},
{
"cell_type": "code",
"execution_count": 90,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"'上'"
]
},
"execution_count": 90,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"obj[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"(he + didnt + verb * 3 + obj)[2:6] # 包括第2,但不包括第6,从第0开始"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 布尔型及其运算"
]
},
{
"cell_type": "code",
"execution_count": 91,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 91,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bmi > 25"
]
},
{
"cell_type": "code",
"execution_count": 92,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"bool"
]
},
"execution_count": 92,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(bmi > 25)"
]
},
{
"cell_type": "code",
"execution_count": 93,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 93,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bmi > 20"
]
},
{
"cell_type": "code",
"execution_count": 94,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 94,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bmi > 20 and not bmi > 25 # and, or, not"
]
},
{
"cell_type": "code",
"execution_count": 95,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 95,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bmi > 20 and bmi < 25 # 更符合阅读习惯的写法"
]
},
{
"cell_type": "code",
"execution_count": 96,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 96,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bmi == bmi or bmi != bmi # 完全正确"
]
},
{
"cell_type": "code",
"execution_count": 97,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 97,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bmi == he or bmi != he "
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 分支"
]
},
{
"cell_type": "code",
"execution_count": 98,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"bmi = 40\n",
"if bmi > 40: # Python用缩进区分block\n",
" print(\"hyper obese\") # 注意这行的开头有TAB"
]
},
{
"cell_type": "code",
"execution_count": 99,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"hyper obese\n"
]
}
],
"source": [
"bmi = 45 # 改变bmi,观察分支选择\n",
"if bmi > 40:\n",
" print(\"hyper obese\")\n",
"else:\n",
" print(\"not hyper obese\")"
]
},
{
"cell_type": "code",
"execution_count": 100,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"hyper obese\n"
]
}
],
"source": [
"# 对bmi值进行分类\n",
"if bmi > 40:\n",
" print(\"hyper obese\")\n",
"elif bmi > 35 and bmi <= 40:\n",
" print(\"super obese\")\n",
"elif bmi > 30 and bmi <= 35:\n",
" print(\"obese\")\n",
"elif bmi > 25 and bmi <= 30:\n",
" print(\"over weight\")\n",
"elif bmi > 18.5 and bmi <= 25:\n",
" print(\"normal\")\n",
"elif bmi > 16 and bmi <= 18.5:\n",
" print(\"under weight\")\n",
"else :\n",
" print(\"slim\") # https://en.wikipedia.org/wiki/Body_mass_index"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"#### 根据[肥胖分类定义](https://en.wikipedia.org/wiki/Body_mass_index)补全上面的分类代码\n",
"\n",
"| type | from | to |\n",
"|---------------------------|------|------|\n",
"| very severely underweight | | 15 |\n",
"| severely underweight | 15 | 16 |\n",
"| underweight | 16 | 18.5 |\n",
"| normal | 18.5 | 25 |\n",
"| overweight | 25 | 30 |\n",
"| moderately obese | 30 | 35 |\n",
"| severely obese | 35 | 40 |\n",
"| very severely obese | 40 | 45 |\n",
"| morbidly obese | 45 | 50 |\n",
"| super obese | 50 | 60 |\n",
"| hyper obese | 60 | |\n",
"\n",
">可见,各个种族,地区,年龄段对于肥胖的定义是有很大差别的"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# 列表和循环"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 列表是数据的容器\n",
">已经学过一种容器:str"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 列表及其运算\n",
"- 从通用List开始\n",
"- 以后基本只关注数值类型容器\n",
"- 注意程序语言和数学语言的映射"
]
},
{
"cell_type": "code",
"execution_count": 101,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['他', '没', '上', '上', '上', '上', '海', '的', '车']"
]
},
"execution_count": 101,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ret = he + didnt + verb * 3 + obj # 用一个变量保存计算结果\n",
"l = list(ret) # 转换为列表\n",
"l # 可以把一个字符串转换为列表,反之?"
]
},
{
"cell_type": "code",
"execution_count": 102,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"list"
]
},
"execution_count": 102,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(l)"
]
},
{
"cell_type": "code",
"execution_count": 103,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['上', '上', '上', '上']"
]
},
"execution_count": 103,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"l[2:6] # 重复之前的操作,取出'上'"
]
},
{
"cell_type": "code",
"execution_count": 104,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['他', '没']"
]
},
"execution_count": 104,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"l[:2] # 到第2个为止,不包括第2个,从第0个开始"
]
},
{
"cell_type": "code",
"execution_count": 105,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['上', '上', '上', '上', '海', '的', '车']"
]
},
"execution_count": 105,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"l[2:] # 从第2个开始"
]
},
{
"cell_type": "code",
"execution_count": 106,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"'车'"
]
},
"execution_count": 106,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"l[-1] # 最后一个,或者,从右边开始第1个,注意不是从第0个开始"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"##### 负数索引\n",
"\n",
"|-9|-8|-7|-6|-5|-4|-3|-2|-1|0|1|2|3|4|5|6|7|8|\n",
"|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|\n",
"|他|没|上|上|上|上|海|的|车|他|没|上|上|上|上|海|的|车|"
]
},
{
"cell_type": "code",
"execution_count": 107,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['的']"
]
},
"execution_count": 107,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"l[-2:-1] # 虽然索引是从右往左计数的,但范围和这些数字的排列顺序是一致的"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"|-9|-8|-7|-6|-5|-4|-3|-2|-1|0|1|2|3|4|5|6|7|8|\n",
"|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|\n",
"|他|没|上|上|上|上|海|的|车|他|没|上|上|上|上|海|的|车|"
]
},
{
"cell_type": "code",
"execution_count": 108,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['的', '车']"
]
},
"execution_count": 108,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"l[-2:]"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"|-9|-8|-7|-6|-5|-4|-3|-2|-1|0|1|2|3|4|5|6|7|8|\n",
"|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|\n",
"|他|没|上|上|上|上|海|的|车|他|没|上|上|上|上|海|的|车|"
]
},
{
"cell_type": "code",
"execution_count": 109,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['上', '上', '上', '上']"
]
},
"execution_count": 109,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"l[-7:-3]"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"|-9|-8|-7|-6|-5|-4|-3|-2|-1|0|1|2|3|4|5|6|7|8|\n",
"|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|\n",
"|他|没|上|上|上|上|海|的|车|他|没|上|上|上|上|海|的|车|"
]
},
{
"cell_type": "code",
"execution_count": 110,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['他', '没', '上', '上', '上', '上', '海', '的', '车']"
]
},
"execution_count": 110,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"l[:]"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"|-9|-8|-7|-6|-5|-4|-3|-2|-1|0|1|2|3|4|5|6|7|8|\n",
"|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|\n",
"|他|没|上|上|上|上|海|的|车|他|没|上|上|上|上|海|的|车|"
]
},
{
"cell_type": "code",
"execution_count": 111,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"9"
]
},
"execution_count": 111,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(l)"
]
},
{
"cell_type": "code",
"execution_count": 112,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"18"
]
},
"execution_count": 112,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c = [6, 7, 3, 3, 3, 3, 10, 8, 4] # 特征:笔画数\n",
"f = l + c\n",
"len(f)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"f"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"#### 列表里面的数据可以是不同类型的"
]
},
{
"cell_type": "code",
"execution_count": 113,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['他', '没', '上', '上', '上', '上', '海', '的', '车', 0, 7, 3, 3, 3, 3, 10, 8, 4]"
]
},
"execution_count": 113,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"g = f # g只是f的另一个名字\n",
"g[9] = 0 # 改变列表\n",
"f # f也会跟着变化"
]
},
{
"cell_type": "code",
"execution_count": 114,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['他', '没', '上', '上', '上', '上', '海', '的', '车', 0, 7, 3, 3, 3, 3, 10, 8, 4]"
]
},
"execution_count": 114,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"g = list(f) # 新创建一个列表\n",
"f[9] = 6 # 改回去\n",
"g # g[9]仍然是0"
]
},
{
"cell_type": "code",
"execution_count": 115,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['他', '没', '上', '上', '上', '上', '海', '的', '车', 7, 3, 3, 3, 3, 10, 8, 4]"
]
},
"execution_count": 115,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"del g[9] # 删掉第9个元素\n",
"g"
]
},
{
"cell_type": "code",
"execution_count": 116,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
"text/plain": [
"17"
]
},
"execution_count": 116,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(g)"
]
},
{
"cell_type": "code",
"execution_count": 117,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
"text/plain": [
"18"
]
},
"execution_count": 117,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(f)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 循环"
]
},
{
"cell_type": "code",
"execution_count": 118,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n"
]
}
],
"source": [
"for v in f:\n",
" print(type(v)) # 注意这行的开头有TAB"
]
},
{
"cell_type": "code",
"execution_count": 119,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 119,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(range(1)) # 只生成一个数"
]
},
{
"cell_type": "code",
"execution_count": 120,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 120,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"range(1)[0] # 这个数是0"
]
},
{
"cell_type": "code",
"execution_count": 121,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"range(0, 18)"
]
},
"execution_count": 121,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"range(len(f)) # f → f的索引"
]
},
{
"cell_type": "code",
"execution_count": 122,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 \n",
"1 \n",
"2 \n",
"3 \n",
"4 \n",
"5 \n",
"6 \n",
"7 \n",
"8 \n",
"9 \n",
"10 \n",
"11 \n",
"12 \n",
"13 \n",
"14 \n",
"15 \n",
"16 \n",
"17 \n"
]
}
],
"source": [
"for i in range(len(f)): # 以索引做循环变量\n",
" print(i, type(f[i]))"
]
},
{
"cell_type": "code",
"execution_count": 123,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 \n",
"1 \n",
"2 \n",
"3 \n",
"4 \n",
"5 \n",
"6 \n",
"7 \n",
"8 \n",
"9 \n",
"10 \n",
"11 \n",
"12 \n",
"13 \n",
"14 \n",
"15 \n",
"16 \n",
"17 \n"
]
}
],
"source": [
"for i, v in enumerate(f): # 上例的简化版本\n",
" print(i, type(v))"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# 函数和库"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 函数的例子"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"#### 问题:求阶乘\\begin{equation}n!\\end{equation}"
]
},
{
"cell_type": "code",
"execution_count": 124,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"120"
]
},
"execution_count": 124,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def fac(n): # 求阶乘\n",
" if n == 1: # 收敛条件\n",
" return 1\n",
" else:\n",
" return n * fac(n - 1) # 递归引用本函数的函数名\n",
"fac(5)"
]
},
{
"cell_type": "code",
"execution_count": 125,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"ename": "RecursionError",
"evalue": "maximum recursion depth exceeded in comparison",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mRecursionError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m9\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# 需要解决fac函数的一个bug\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfac\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m\u001b[0m in \u001b[0;36mfac\u001b[0;34m(n)\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mn\u001b[0m \u001b[0;34m*\u001b[0m \u001b[0mfac\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# 递归引用本函数的函数名\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0mfac\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"... last 1 frames repeated, from the frame below ...\n",
"\u001b[0;32m\u001b[0m in \u001b[0;36mfac\u001b[0;34m(n)\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mn\u001b[0m \u001b[0;34m*\u001b[0m \u001b[0mfac\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# 递归引用本函数的函数名\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0mfac\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mRecursionError\u001b[0m: maximum recursion depth exceeded in comparison"
]
}
],
"source": [
"for i in range(9): # 需要解决fac函数的一个bug\n",
" print(fac(i))"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"#### \\begin{equation}0!=1\\end{equation}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"fac(0)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"#### 用循环来定义阶乘函数\n",
"```python\n",
"def fac_loop(n):\n",
" ret = 1\n",
" for i in range(n):\n",
" ret = ret * (i + 1)\n",
" return ret\n",
"```\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"def fac_loop(n):\n",
" ret = 1\n",
" for i in range(n):\n",
" ret = ret * (i + 1)\n",
" return ret\n",
"print(fac_loop(5))\n",
"print(fac_loop(0))\n",
"print(fac_loop(1))"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"#### 问题:求组合数 \\begin{equation}{n\\choose k}=\\frac{n!}{(n-k)!k!}\\end{equation}"
]
},
{
"cell_type": "code",
"execution_count": 126,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"270725.0"
]
},
"execution_count": 126,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def combination(n, k): # 求组合数\n",
" return fac(n) / (fac(n - k) * fac(k))\n",
"combination(52, 4)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 函数的类型"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"##### 函数的类型?\n",
"```python\n",
"type(fac)\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 127,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"function"
]
},
"execution_count": 127,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(fac) # 和type(True)不是一样?"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
">函数的类型是参数类型到返回值类型两个类型集合的映射关系\n",
"#### \\begin{equation} fac : int→int \\end{equation}\\begin{equation} combination: int, int → int \\end{equation}"
]
},
{
"cell_type": "code",
"execution_count": 128,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"47"
]
},
"execution_count": 128,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"max([23, 37, 13, 47]) # 输入类型是一个list,输出类型是一个数值"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 方法\n",
">第一个参数是固定函数"
]
},
{
"cell_type": "code",
"execution_count": 129,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[13, 23, 37, 47]"
]
},
"execution_count": 129,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pl = [23, 37, 13, 47]\n",
"pl.sort() # 输入类型是一个list,输出类型是一个list,类型实例和函数名之间用一个.连接\n",
"pl"
]
},
{
"cell_type": "code",
"execution_count": 130,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Help on method_descriptor:\n",
"\n",
"sort(...)\n",
" L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE*\n",
"\n"
]
}
],
"source": [
"help(list.sort) # 获得在线帮助"
]
},
{
"cell_type": "code",
"execution_count": 131,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[47, 37, 23, 13]"
]
},
"execution_count": 131,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pl.sort(reverse=True) # 命名参数\n",
"pl"
]
},
{
"cell_type": "code",
"execution_count": 132,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Help on class list in module builtins:\n",
"\n",
"class list(object)\n",
" | list() -> new empty list\n",
" | list(iterable) -> new list initialized from iterable's items\n",
" | \n",
" | Methods defined here:\n",
" | \n",
" | __add__(self, value, /)\n",
" | Return self+value.\n",
" | \n",
" | __contains__(self, key, /)\n",
" | Return key in self.\n",
" | \n",
" | __delitem__(self, key, /)\n",
" | Delete self[key].\n",
" | \n",
" | __eq__(self, value, /)\n",
" | Return self==value.\n",
" | \n",
" | __ge__(self, value, /)\n",
" | Return self>=value.\n",
" | \n",
" | __getattribute__(self, name, /)\n",
" | Return getattr(self, name).\n",
" | \n",
" | __getitem__(...)\n",
" | x.__getitem__(y) <==> x[y]\n",
" | \n",
" | __gt__(self, value, /)\n",
" | Return self>value.\n",
" | \n",
" | __iadd__(self, value, /)\n",
" | Implement self+=value.\n",
" | \n",
" | __imul__(self, value, /)\n",
" | Implement self*=value.\n",
" | \n",
" | __init__(self, /, *args, **kwargs)\n",
" | Initialize self. See help(type(self)) for accurate signature.\n",
" | \n",
" | __iter__(self, /)\n",
" | Implement iter(self).\n",
" | \n",
" | __le__(self, value, /)\n",
" | Return self<=value.\n",
" | \n",
" | __len__(self, /)\n",
" | Return len(self).\n",
" | \n",
" | __lt__(self, value, /)\n",
" | Return self None -- append object to end\n",
" | \n",
" | clear(...)\n",
" | L.clear() -> None -- remove all items from L\n",
" | \n",
" | copy(...)\n",
" | L.copy() -> list -- a shallow copy of L\n",
" | \n",
" | count(...)\n",
" | L.count(value) -> integer -- return number of occurrences of value\n",
" | \n",
" | extend(...)\n",
" | L.extend(iterable) -> None -- extend list by appending elements from the iterable\n",
" | \n",
" | index(...)\n",
" | L.index(value, [start, [stop]]) -> integer -- return first index of value.\n",
" | Raises ValueError if the value is not present.\n",
" | \n",
" | insert(...)\n",
" | L.insert(index, object) -- insert object before index\n",
" | \n",
" | pop(...)\n",
" | L.pop([index]) -> item -- remove and return item at index (default last).\n",
" | Raises IndexError if list is empty or index is out of range.\n",
" | \n",
" | remove(...)\n",
" | L.remove(value) -> None -- remove first occurrence of value.\n",
" | Raises ValueError if the value is not present.\n",
" | \n",
" | reverse(...)\n",
" | L.reverse() -- reverse *IN PLACE*\n",
" | \n",
" | sort(...)\n",
" | L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE*\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Data and other attributes defined here:\n",
" | \n",
" | __hash__ = None\n",
"\n"
]
}
],
"source": [
"help(list) # 列出list的全部方法"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"#### 问题:伟人排序\n",
"|像|姓名|出生年|寿命|\n",
"|-|-|-|-|\n",
"|  | 佛陀 | 480BC | 80 |\n",
"|  | 孔子 | 551BC | 73 |\n",
"|  | 柏拉图 | 428BC | 80 |\n",
"|  | 琐罗亚斯德 | 500BC | ? |\n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 133,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"# 新数据类型:dict\n",
"great = [{'name':'Buddha', 'birth':-480, 'age':80}, \n",
" {'name':'Confucius', 'birth':-551, 'age':73}, \n",
" {'name':'Plato', 'birth':-428, 'age':80}, \n",
" {'name':'Zoroaster', 'birth':-500, 'age':float('nan')}]"
]
},
{
"cell_type": "code",
"execution_count": 134,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"'Buddha'"
]
},
"execution_count": 134,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"great[0]['name'] # dict可以按照名字索引"
]
},
{
"cell_type": "code",
"execution_count": 135,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"73"
]
},
"execution_count": 135,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"great[1]['age'] # dict本身可以是list的元素"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"##### 无名函数\n",
"\\begin{equation}\\lambda\\end{equation}\n",
">先定义一个函数再使用它有时不如在用它的地方定义它"
]
},
{
"cell_type": "code",
"execution_count": 136,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[{'name': 'Buddha', 'birth': -480, 'age': 80},\n",
" {'name': 'Plato', 'birth': -428, 'age': 80},\n",
" {'name': 'Confucius', 'birth': -551, 'age': 73},\n",
" {'name': 'Zoroaster', 'birth': -500, 'age': nan}]"
]
},
"execution_count": 136,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"great = [{'name':'Buddha', 'birth':-480, 'age':80}, \n",
" {'name':'Confucius', 'birth':-551, 'age':73}, \n",
" {'name':'Plato', 'birth':-428, 'age':80}, \n",
" {'name':'Zoroaster', 'birth':-500, 'age':float('nan')}]\n",
"great.sort(key=lambda person: person['age'], reverse=True) # key 参数要求一个函数类型,lambda在这里非常方便\n",
"great"
]
},
{
"cell_type": "code",
"execution_count": 137,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[{'name': 'Confucius', 'birth': -551, 'age': 73},\n",
" {'name': 'Zoroaster', 'birth': -500, 'age': nan},\n",
" {'name': 'Buddha', 'birth': -480, 'age': 80},\n",
" {'name': 'Plato', 'birth': -428, 'age': 80}]"
]
},
"execution_count": 137,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"great = [{'name':'Buddha', 'birth':-480, 'age':80}, \n",
" {'name':'Confucius', 'birth':-551, 'age':73}, \n",
" {'name':'Plato', 'birth':-428, 'age':80}, \n",
" {'name':'Zoroaster', 'birth':-500, 'age':float('nan')}]\n",
"great.sort(key=lambda o: o['birth'])\n",
"great"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 库的安装和引用"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"```sh\n",
"pip3 install algorithms\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"```sh\n",
"python3 -c 'from algorithms.sort import merge_sort'\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"from algorithms.sort import merge_sort\n",
"test_list = [1, 8, 3, 5, 6]\n",
"result_list = merge_sort(test_list)\n",
"result_list"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"##### 在哪里找到这些库?\n",
"[pypi](https://pypi.org/)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Numpy\n",
"\n",
"[numpy的功能](https://www.numpy.org/devdocs/user/quickstart.html)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 引入Numpy的目的\n",
"\n",
"- 为何不直接用list?\n",
" - 慢\n",
" - 缺少数学操作"
]
},
{
"cell_type": "code",
"execution_count": 139,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"ename": "TypeError",
"evalue": "unsupported operand type(s) for ** or pow(): 'list' and 'int'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mheights\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;36m1.73\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1.68\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1.71\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1.89\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1.79\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;31m# 5人的身高\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mweights\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;36m65.4\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m59.2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m63.6\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m88.4\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m68.7\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;31m# 5人的体重\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mbmis\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mweights\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0mheights\u001b[0m \u001b[0;34m**\u001b[0m \u001b[0;36m2\u001b[0m \u001b[0;31m# 却不能直接计算5人的BMI\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for ** or pow(): 'list' and 'int'"
]
}
],
"source": [
"heights = [1.73, 1.68, 1.71, 1.89, 1.79] # 5人的身高\n",
"weights = [65.4, 59.2, 63.6, 88.4, 68.7] # 5人的体重\n",
"bmis = weights / heights ** 2 # 却不能直接计算5人的BMI"
]
},
{
"cell_type": "code",
"execution_count": 140,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([21.85171573, 20.97505669, 21.75028214, 24.7473475 , 21.44127836])"
]
},
"execution_count": 140,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np \n",
"np_heights = np.array(heights) # array,向量,通常只包含数值\n",
"np_weights = np.array(weights)\n",
"bmis = np_weights / np_heights ** 2 # 这里计算的单元是一个向量\n",
"bmis"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"##### 更新BMI公式,现在是对向量做计算\n",
"\\begin{equation}\\vec{BMIS} = \\frac{\\vec{weights}}{\\vec{heights}^{2}}\\end{equation}"
]
},
{
"cell_type": "code",
"execution_count": 141,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([ True, False, True, True, True])"
]
},
"execution_count": 141,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bmis > 21 # 符合直觉的结果,"
]
},
{
"cell_type": "code",
"execution_count": 142,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"ename": "TypeError",
"evalue": "type numpy.ndarray doesn't define __round__ method",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mround\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbmis\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# 只有numpy.ndarray支持的方法\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: type numpy.ndarray doesn't define __round__ method"
]
}
],
"source": [
"round(bmis) # 只有numpy.ndarray支持的方法"
]
},
{
"cell_type": "code",
"execution_count": 143,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([22., 21., 22., 25., 21.])"
]
},
"execution_count": 143,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.round(bmis) # 需要使用np重载的方法"
]
},
{
"cell_type": "code",
"execution_count": 144,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 144,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.max(bmis) == max(bmis) # 大胆地猜想这两种方法应该都可以"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Help on class ndarray in module numpy:\n",
"\n",
"class ndarray(builtins.object)\n",
" | ndarray(shape, dtype=float, buffer=None, offset=0,\n",
" | strides=None, order=None)\n",
" | \n",
" | An array object represents a multidimensional, homogeneous array\n",
" | of fixed-size items. An associated data-type object describes the\n",
" | format of each element in the array (its byte-order, how many bytes it\n",
" | occupies in memory, whether it is an integer, a floating point number,\n",
" | or something else, etc.)\n",
" | \n",
" | Arrays should be constructed using `array`, `zeros` or `empty` (refer\n",
" | to the See Also section below). The parameters given here refer to\n",
" | a low-level method (`ndarray(...)`) for instantiating an array.\n",
" | \n",
" | For more information, refer to the `numpy` module and examine the\n",
" | methods and attributes of an array.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | (for the __new__ method; see Notes below)\n",
" | \n",
" | shape : tuple of ints\n",
" | Shape of created array.\n",
" | dtype : data-type, optional\n",
" | Any object that can be interpreted as a numpy data type.\n",
" | buffer : object exposing buffer interface, optional\n",
" | Used to fill the array with data.\n",
" | offset : int, optional\n",
" | Offset of array data in buffer.\n",
" | strides : tuple of ints, optional\n",
" | Strides of data in memory.\n",
" | order : {'C', 'F'}, optional\n",
" | Row-major (C-style) or column-major (Fortran-style) order.\n",
" | \n",
" | Attributes\n",
" | ----------\n",
" | T : ndarray\n",
" | Transpose of the array.\n",
" | data : buffer\n",
" | The array's elements, in memory.\n",
" | dtype : dtype object\n",
" | Describes the format of the elements in the array.\n",
" | flags : dict\n",
" | Dictionary containing information related to memory use, e.g.,\n",
" | 'C_CONTIGUOUS', 'OWNDATA', 'WRITEABLE', etc.\n",
" | flat : numpy.flatiter object\n",
" | Flattened version of the array as an iterator. The iterator\n",
" | allows assignments, e.g., ``x.flat = 3`` (See `ndarray.flat` for\n",
" | assignment examples; TODO).\n",
" | imag : ndarray\n",
" | Imaginary part of the array.\n",
" | real : ndarray\n",
" | Real part of the array.\n",
" | size : int\n",
" | Number of elements in the array.\n",
" | itemsize : int\n",
" | The memory use of each array element in bytes.\n",
" | nbytes : int\n",
" | The total number of bytes required to store the array data,\n",
" | i.e., ``itemsize * size``.\n",
" | ndim : int\n",
" | The array's number of dimensions.\n",
" | shape : tuple of ints\n",
" | Shape of the array.\n",
" | strides : tuple of ints\n",
" | The step-size required to move from one element to the next in\n",
" | memory. For example, a contiguous ``(3, 4)`` array of type\n",
" | ``int16`` in C-order has strides ``(8, 2)``. This implies that\n",
" | to move from element to element in memory requires jumps of 2 bytes.\n",
" | To move from row-to-row, one needs to jump 8 bytes at a time\n",
" | (``2 * 4``).\n",
" | ctypes : ctypes object\n",
" | Class containing properties of the array needed for interaction\n",
" | with ctypes.\n",
" | base : ndarray\n",
" | If the array is a view into another array, that array is its `base`\n",
" | (unless that array is also a view). The `base` array is where the\n",
" | array data is actually stored.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | array : Construct an array.\n",
" | zeros : Create an array, each element of which is zero.\n",
" | empty : Create an array, but leave its allocated memory unchanged (i.e.,\n",
" | it contains \"garbage\").\n",
" | dtype : Create a data-type.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | There are two modes of creating an array using ``__new__``:\n",
" | \n",
" | 1. If `buffer` is None, then only `shape`, `dtype`, and `order`\n",
" | are used.\n",
" | 2. If `buffer` is an object exposing the buffer interface, then\n",
" | all keywords are interpreted.\n",
" | \n",
" | No ``__init__`` method is needed because the array is fully initialized\n",
" | after the ``__new__`` method.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | These examples illustrate the low-level `ndarray` constructor. Refer\n",
" | to the `See Also` section above for easier ways of constructing an\n",
" | ndarray.\n",
" | \n",
" | First mode, `buffer` is None:\n",
" | \n",
" | >>> np.ndarray(shape=(2,2), dtype=float, order='F')\n",
" | array([[ -1.13698227e+002, 4.25087011e-303],\n",
" | [ 2.88528414e-306, 3.27025015e-309]]) #random\n",
" | \n",
" | Second mode:\n",
" | \n",
" | >>> np.ndarray((2,), buffer=np.array([1,2,3]),\n",
" | ... offset=np.int_().itemsize,\n",
" | ... dtype=int) # offset = 1*itemsize, i.e. skip first element\n",
" | array([2, 3])\n",
" | \n",
" | Methods defined here:\n",
" | \n",
" | __abs__(self, /)\n",
" | abs(self)\n",
" | \n",
" | __add__(self, value, /)\n",
" | Return self+value.\n",
" | \n",
" | __and__(self, value, /)\n",
" | Return self&value.\n",
" | \n",
" | __array__(...)\n",
" | a.__array__(|dtype) -> reference if type unchanged, copy otherwise.\n",
" | \n",
" | Returns either a new reference to self if dtype is not given or a new array\n",
" | of provided data type if dtype is different from the current dtype of the\n",
" | array.\n",
" | \n",
" | __array_function__(...)\n",
" | \n",
" | __array_prepare__(...)\n",
" | a.__array_prepare__(obj) -> Object of same type as ndarray object obj.\n",
" | \n",
" | __array_ufunc__(...)\n",
" | \n",
" | __array_wrap__(...)\n",
" | a.__array_wrap__(obj) -> Object of same type as ndarray object a.\n",
" | \n",
" | __bool__(self, /)\n",
" | self != 0\n",
" | \n",
" | __complex__(...)\n",
" | \n",
" | __contains__(self, key, /)\n",
" | Return key in self.\n",
" | \n",
" | __copy__(...)\n",
" | a.__copy__()\n",
" | \n",
" | Used if :func:`copy.copy` is called on an array. Returns a copy of the array.\n",
" | \n",
" | Equivalent to ``a.copy(order='K')``.\n",
" | \n",
" | __deepcopy__(...)\n",
" | a.__deepcopy__(memo, /) -> Deep copy of array.\n",
" | \n",
" | Used if :func:`copy.deepcopy` is called on an array.\n",
" | \n",
" | __delitem__(self, key, /)\n",
" | Delete self[key].\n",
" | \n",
" | __divmod__(self, value, /)\n",
" | Return divmod(self, value).\n",
" | \n",
" | __eq__(self, value, /)\n",
" | Return self==value.\n",
" | \n",
" | __float__(self, /)\n",
" | float(self)\n",
" | \n",
" | __floordiv__(self, value, /)\n",
" | Return self//value.\n",
" | \n",
" | __format__(...)\n",
" | default object formatter\n",
" | \n",
" | __ge__(self, value, /)\n",
" | Return self>=value.\n",
" | \n",
" | __getitem__(self, key, /)\n",
" | Return self[key].\n",
" | \n",
" | __gt__(self, value, /)\n",
" | Return self>value.\n",
" | \n",
" | __iadd__(self, value, /)\n",
" | Return self+=value.\n",
" | \n",
" | __iand__(self, value, /)\n",
" | Return self&=value.\n",
" | \n",
" | __ifloordiv__(self, value, /)\n",
" | Return self//=value.\n",
" | \n",
" | __ilshift__(self, value, /)\n",
" | Return self<<=value.\n",
" | \n",
" | __imatmul__(self, value, /)\n",
" | Return self@=value.\n",
" | \n",
" | __imod__(self, value, /)\n",
" | Return self%=value.\n",
" | \n",
" | __imul__(self, value, /)\n",
" | Return self*=value.\n",
" | \n",
" | __index__(self, /)\n",
" | Return self converted to an integer, if self is suitable for use as an index into a list.\n",
" | \n",
" | __int__(self, /)\n",
" | int(self)\n",
" | \n",
" | __invert__(self, /)\n",
" | ~self\n",
" | \n",
" | __ior__(self, value, /)\n",
" | Return self|=value.\n",
" | \n",
" | __ipow__(self, value, /)\n",
" | Return self**=value.\n",
" | \n",
" | __irshift__(self, value, /)\n",
" | Return self>>=value.\n",
" | \n",
" | __isub__(self, value, /)\n",
" | Return self-=value.\n",
" | \n",
" | __iter__(self, /)\n",
" | Implement iter(self).\n",
" | \n",
" | __itruediv__(self, value, /)\n",
" | Return self/=value.\n",
" | \n",
" | __ixor__(self, value, /)\n",
" | Return self^=value.\n",
" | \n",
" | __le__(self, value, /)\n",
" | Return self<=value.\n",
" | \n",
" | __len__(self, /)\n",
" | Return len(self).\n",
" | \n",
" | __lshift__(self, value, /)\n",
" | Return self<>self.\n",
" | \n",
" | __rshift__(self, value, /)\n",
" | Return self>>value.\n",
" | \n",
" | __rsub__(self, value, /)\n",
" | Return value-self.\n",
" | \n",
" | __rtruediv__(self, value, /)\n",
" | Return value/self.\n",
" | \n",
" | __rxor__(self, value, /)\n",
" | Return value^self.\n",
" | \n",
" | __setitem__(self, key, value, /)\n",
" | Set self[key] to value.\n",
" | \n",
" | __setstate__(...)\n",
" | a.__setstate__(state, /)\n",
" | \n",
" | For unpickling.\n",
" | \n",
" | The `state` argument must be a sequence that contains the following\n",
" | elements:\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | version : int\n",
" | optional pickle version. If omitted defaults to 0.\n",
" | shape : tuple\n",
" | dtype : data-type\n",
" | isFortran : bool\n",
" | rawdata : string or list\n",
" | a binary string with the data (or a list if 'a' is an object array)\n",
" | \n",
" | __sizeof__(...)\n",
" | __sizeof__() -> int\n",
" | size of object in memory, in bytes\n",
" | \n",
" | __str__(self, /)\n",
" | Return str(self).\n",
" | \n",
" | __sub__(self, value, /)\n",
" | Return self-value.\n",
" | \n",
" | __truediv__(self, value, /)\n",
" | Return self/value.\n",
" | \n",
" | __xor__(self, value, /)\n",
" | Return self^value.\n",
" | \n",
" | all(...)\n",
" | a.all(axis=None, out=None, keepdims=False)\n",
" | \n",
" | Returns True if all elements evaluate to True.\n",
" | \n",
" | Refer to `numpy.all` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.all : equivalent function\n",
" | \n",
" | any(...)\n",
" | a.any(axis=None, out=None, keepdims=False)\n",
" | \n",
" | Returns True if any of the elements of `a` evaluate to True.\n",
" | \n",
" | Refer to `numpy.any` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.any : equivalent function\n",
" | \n",
" | argmax(...)\n",
" | a.argmax(axis=None, out=None)\n",
" | \n",
" | Return indices of the maximum values along the given axis.\n",
" | \n",
" | Refer to `numpy.argmax` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.argmax : equivalent function\n",
" | \n",
" | argmin(...)\n",
" | a.argmin(axis=None, out=None)\n",
" | \n",
" | Return indices of the minimum values along the given axis of `a`.\n",
" | \n",
" | Refer to `numpy.argmin` for detailed documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.argmin : equivalent function\n",
" | \n",
" | argpartition(...)\n",
" | a.argpartition(kth, axis=-1, kind='introselect', order=None)\n",
" | \n",
" | Returns the indices that would partition this array.\n",
" | \n",
" | Refer to `numpy.argpartition` for full documentation.\n",
" | \n",
" | .. versionadded:: 1.8.0\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.argpartition : equivalent function\n",
" | \n",
" | argsort(...)\n",
" | a.argsort(axis=-1, kind='quicksort', order=None)\n",
" | \n",
" | Returns the indices that would sort this array.\n",
" | \n",
" | Refer to `numpy.argsort` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.argsort : equivalent function\n",
" | \n",
" | astype(...)\n",
" | a.astype(dtype, order='K', casting='unsafe', subok=True, copy=True)\n",
" | \n",
" | Copy of the array, cast to a specified type.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | dtype : str or dtype\n",
" | Typecode or data-type to which the array is cast.\n",
" | order : {'C', 'F', 'A', 'K'}, optional\n",
" | Controls the memory layout order of the result.\n",
" | 'C' means C order, 'F' means Fortran order, 'A'\n",
" | means 'F' order if all the arrays are Fortran contiguous,\n",
" | 'C' order otherwise, and 'K' means as close to the\n",
" | order the array elements appear in memory as possible.\n",
" | Default is 'K'.\n",
" | casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional\n",
" | Controls what kind of data casting may occur. Defaults to 'unsafe'\n",
" | for backwards compatibility.\n",
" | \n",
" | * 'no' means the data types should not be cast at all.\n",
" | * 'equiv' means only byte-order changes are allowed.\n",
" | * 'safe' means only casts which can preserve values are allowed.\n",
" | * 'same_kind' means only safe casts or casts within a kind,\n",
" | like float64 to float32, are allowed.\n",
" | * 'unsafe' means any data conversions may be done.\n",
" | subok : bool, optional\n",
" | If True, then sub-classes will be passed-through (default), otherwise\n",
" | the returned array will be forced to be a base-class array.\n",
" | copy : bool, optional\n",
" | By default, astype always returns a newly allocated array. If this\n",
" | is set to false, and the `dtype`, `order`, and `subok`\n",
" | requirements are satisfied, the input array is returned instead\n",
" | of a copy.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | arr_t : ndarray\n",
" | Unless `copy` is False and the other conditions for returning the input\n",
" | array are satisfied (see description for `copy` input parameter), `arr_t`\n",
" | is a new array of the same shape as the input array, with dtype, order\n",
" | given by `dtype`, `order`.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | Starting in NumPy 1.9, astype method now returns an error if the string\n",
" | dtype to cast to is not long enough in 'safe' casting mode to hold the max\n",
" | value of integer/float array that is being casted. Previously the casting\n",
" | was allowed even if the result was truncated.\n",
" | \n",
" | Raises\n",
" | ------\n",
" | ComplexWarning\n",
" | When casting from complex to float or int. To avoid this,\n",
" | one should use ``a.real.astype(t)``.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.array([1, 2, 2.5])\n",
" | >>> x\n",
" | array([ 1. , 2. , 2.5])\n",
" | \n",
" | >>> x.astype(int)\n",
" | array([1, 2, 2])\n",
" | \n",
" | byteswap(...)\n",
" | a.byteswap(inplace=False)\n",
" | \n",
" | Swap the bytes of the array elements\n",
" | \n",
" | Toggle between low-endian and big-endian data representation by\n",
" | returning a byteswapped array, optionally swapped in-place.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | inplace : bool, optional\n",
" | If ``True``, swap bytes in-place, default is ``False``.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | out : ndarray\n",
" | The byteswapped array. If `inplace` is ``True``, this is\n",
" | a view to self.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> A = np.array([1, 256, 8755], dtype=np.int16)\n",
" | >>> map(hex, A)\n",
" | ['0x1', '0x100', '0x2233']\n",
" | >>> A.byteswap(inplace=True)\n",
" | array([ 256, 1, 13090], dtype=int16)\n",
" | >>> map(hex, A)\n",
" | ['0x100', '0x1', '0x3322']\n",
" | \n",
" | Arrays of strings are not swapped\n",
" | \n",
" | >>> A = np.array(['ceg', 'fac'])\n",
" | >>> A.byteswap()\n",
" | array(['ceg', 'fac'],\n",
" | dtype='|S3')\n",
" | \n",
" | choose(...)\n",
" | a.choose(choices, out=None, mode='raise')\n",
" | \n",
" | Use an index array to construct a new array from a set of choices.\n",
" | \n",
" | Refer to `numpy.choose` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.choose : equivalent function\n",
" | \n",
" | clip(...)\n",
" | a.clip(min=None, max=None, out=None)\n",
" | \n",
" | Return an array whose values are limited to ``[min, max]``.\n",
" | One of max or min must be given.\n",
" | \n",
" | Refer to `numpy.clip` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.clip : equivalent function\n",
" | \n",
" | compress(...)\n",
" | a.compress(condition, axis=None, out=None)\n",
" | \n",
" | Return selected slices of this array along given axis.\n",
" | \n",
" | Refer to `numpy.compress` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.compress : equivalent function\n",
" | \n",
" | conj(...)\n",
" | a.conj()\n",
" | \n",
" | Complex-conjugate all elements.\n",
" | \n",
" | Refer to `numpy.conjugate` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.conjugate : equivalent function\n",
" | \n",
" | conjugate(...)\n",
" | a.conjugate()\n",
" | \n",
" | Return the complex conjugate, element-wise.\n",
" | \n",
" | Refer to `numpy.conjugate` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.conjugate : equivalent function\n",
" | \n",
" | copy(...)\n",
" | a.copy(order='C')\n",
" | \n",
" | Return a copy of the array.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | order : {'C', 'F', 'A', 'K'}, optional\n",
" | Controls the memory layout of the copy. 'C' means C-order,\n",
" | 'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous,\n",
" | 'C' otherwise. 'K' means match the layout of `a` as closely\n",
" | as possible. (Note that this function and :func:`numpy.copy` are very\n",
" | similar, but have different default values for their order=\n",
" | arguments.)\n",
" | \n",
" | See also\n",
" | --------\n",
" | numpy.copy\n",
" | numpy.copyto\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.array([[1,2,3],[4,5,6]], order='F')\n",
" | \n",
" | >>> y = x.copy()\n",
" | \n",
" | >>> x.fill(0)\n",
" | \n",
" | >>> x\n",
" | array([[0, 0, 0],\n",
" | [0, 0, 0]])\n",
" | \n",
" | >>> y\n",
" | array([[1, 2, 3],\n",
" | [4, 5, 6]])\n",
" | \n",
" | >>> y.flags['C_CONTIGUOUS']\n",
" | True\n",
" | \n",
" | cumprod(...)\n",
" | a.cumprod(axis=None, dtype=None, out=None)\n",
" | \n",
" | Return the cumulative product of the elements along the given axis.\n",
" | \n",
" | Refer to `numpy.cumprod` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.cumprod : equivalent function\n",
" | \n",
" | cumsum(...)\n",
" | a.cumsum(axis=None, dtype=None, out=None)\n",
" | \n",
" | Return the cumulative sum of the elements along the given axis.\n",
" | \n",
" | Refer to `numpy.cumsum` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.cumsum : equivalent function\n",
" | \n",
" | diagonal(...)\n",
" | a.diagonal(offset=0, axis1=0, axis2=1)\n",
" | \n",
" | Return specified diagonals. In NumPy 1.9 the returned array is a\n",
" | read-only view instead of a copy as in previous NumPy versions. In\n",
" | a future version the read-only restriction will be removed.\n",
" | \n",
" | Refer to :func:`numpy.diagonal` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.diagonal : equivalent function\n",
" | \n",
" | dot(...)\n",
" | a.dot(b, out=None)\n",
" | \n",
" | Dot product of two arrays.\n",
" | \n",
" | Refer to `numpy.dot` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.dot : equivalent function\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> a = np.eye(2)\n",
" | >>> b = np.ones((2, 2)) * 2\n",
" | >>> a.dot(b)\n",
" | array([[ 2., 2.],\n",
" | [ 2., 2.]])\n",
" | \n",
" | This array method can be conveniently chained:\n",
" | \n",
" | >>> a.dot(b).dot(b)\n",
" | array([[ 8., 8.],\n",
" | [ 8., 8.]])\n",
" | \n",
" | dump(...)\n",
" | a.dump(file)\n",
" | \n",
" | Dump a pickle of the array to the specified file.\n",
" | The array can be read back with pickle.load or numpy.load.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | file : str\n",
" | A string naming the dump file.\n",
" | \n",
" | dumps(...)\n",
" | a.dumps()\n",
" | \n",
" | Returns the pickle of the array as a string.\n",
" | pickle.loads or numpy.loads will convert the string back to an array.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | None\n",
" | \n",
" | fill(...)\n",
" | a.fill(value)\n",
" | \n",
" | Fill the array with a scalar value.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | value : scalar\n",
" | All elements of `a` will be assigned this value.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> a = np.array([1, 2])\n",
" | >>> a.fill(0)\n",
" | >>> a\n",
" | array([0, 0])\n",
" | >>> a = np.empty(2)\n",
" | >>> a.fill(1)\n",
" | >>> a\n",
" | array([ 1., 1.])\n",
" | \n",
" | flatten(...)\n",
" | a.flatten(order='C')\n",
" | \n",
" | Return a copy of the array collapsed into one dimension.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | order : {'C', 'F', 'A', 'K'}, optional\n",
" | 'C' means to flatten in row-major (C-style) order.\n",
" | 'F' means to flatten in column-major (Fortran-\n",
" | style) order. 'A' means to flatten in column-major\n",
" | order if `a` is Fortran *contiguous* in memory,\n",
" | row-major order otherwise. 'K' means to flatten\n",
" | `a` in the order the elements occur in memory.\n",
" | The default is 'C'.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | y : ndarray\n",
" | A copy of the input array, flattened to one dimension.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | ravel : Return a flattened array.\n",
" | flat : A 1-D flat iterator over the array.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> a = np.array([[1,2], [3,4]])\n",
" | >>> a.flatten()\n",
" | array([1, 2, 3, 4])\n",
" | >>> a.flatten('F')\n",
" | array([1, 3, 2, 4])\n",
" | \n",
" | getfield(...)\n",
" | a.getfield(dtype, offset=0)\n",
" | \n",
" | Returns a field of the given array as a certain type.\n",
" | \n",
" | A field is a view of the array data with a given data-type. The values in\n",
" | the view are determined by the given type and the offset into the current\n",
" | array in bytes. The offset needs to be such that the view dtype fits in the\n",
" | array dtype; for example an array of dtype complex128 has 16-byte elements.\n",
" | If taking a view with a 32-bit integer (4 bytes), the offset needs to be\n",
" | between 0 and 12 bytes.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | dtype : str or dtype\n",
" | The data type of the view. The dtype size of the view can not be larger\n",
" | than that of the array itself.\n",
" | offset : int\n",
" | Number of bytes to skip before beginning the element view.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.diag([1.+1.j]*2)\n",
" | >>> x[1, 1] = 2 + 4.j\n",
" | >>> x\n",
" | array([[ 1.+1.j, 0.+0.j],\n",
" | [ 0.+0.j, 2.+4.j]])\n",
" | >>> x.getfield(np.float64)\n",
" | array([[ 1., 0.],\n",
" | [ 0., 2.]])\n",
" | \n",
" | By choosing an offset of 8 bytes we can select the complex part of the\n",
" | array for our view:\n",
" | \n",
" | >>> x.getfield(np.float64, offset=8)\n",
" | array([[ 1., 0.],\n",
" | [ 0., 4.]])\n",
" | \n",
" | item(...)\n",
" | a.item(*args)\n",
" | \n",
" | Copy an element of an array to a standard Python scalar and return it.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | \\*args : Arguments (variable number and type)\n",
" | \n",
" | * none: in this case, the method only works for arrays\n",
" | with one element (`a.size == 1`), which element is\n",
" | copied into a standard Python scalar object and returned.\n",
" | \n",
" | * int_type: this argument is interpreted as a flat index into\n",
" | the array, specifying which element to copy and return.\n",
" | \n",
" | * tuple of int_types: functions as does a single int_type argument,\n",
" | except that the argument is interpreted as an nd-index into the\n",
" | array.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | z : Standard Python scalar object\n",
" | A copy of the specified element of the array as a suitable\n",
" | Python scalar\n",
" | \n",
" | Notes\n",
" | -----\n",
" | When the data type of `a` is longdouble or clongdouble, item() returns\n",
" | a scalar array object because there is no available Python scalar that\n",
" | would not lose information. Void arrays return a buffer object for item(),\n",
" | unless fields are defined, in which case a tuple is returned.\n",
" | \n",
" | `item` is very similar to a[args], except, instead of an array scalar,\n",
" | a standard Python scalar is returned. This can be useful for speeding up\n",
" | access to elements of the array and doing arithmetic on elements of the\n",
" | array using Python's optimized math.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.random.randint(9, size=(3, 3))\n",
" | >>> x\n",
" | array([[3, 1, 7],\n",
" | [2, 8, 3],\n",
" | [8, 5, 3]])\n",
" | >>> x.item(3)\n",
" | 2\n",
" | >>> x.item(7)\n",
" | 5\n",
" | >>> x.item((0, 1))\n",
" | 1\n",
" | >>> x.item((2, 2))\n",
" | 3\n",
" | \n",
" | itemset(...)\n",
" | a.itemset(*args)\n",
" | \n",
" | Insert scalar into an array (scalar is cast to array's dtype, if possible)\n",
" | \n",
" | There must be at least 1 argument, and define the last argument\n",
" | as *item*. Then, ``a.itemset(*args)`` is equivalent to but faster\n",
" | than ``a[args] = item``. The item should be a scalar value and `args`\n",
" | must select a single item in the array `a`.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | \\*args : Arguments\n",
" | If one argument: a scalar, only used in case `a` is of size 1.\n",
" | If two arguments: the last argument is the value to be set\n",
" | and must be a scalar, the first argument specifies a single array\n",
" | element location. It is either an int or a tuple.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | Compared to indexing syntax, `itemset` provides some speed increase\n",
" | for placing a scalar into a particular location in an `ndarray`,\n",
" | if you must do this. However, generally this is discouraged:\n",
" | among other problems, it complicates the appearance of the code.\n",
" | Also, when using `itemset` (and `item`) inside a loop, be sure\n",
" | to assign the methods to a local variable to avoid the attribute\n",
" | look-up at each loop iteration.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.random.randint(9, size=(3, 3))\n",
" | >>> x\n",
" | array([[3, 1, 7],\n",
" | [2, 8, 3],\n",
" | [8, 5, 3]])\n",
" | >>> x.itemset(4, 0)\n",
" | >>> x.itemset((2, 2), 9)\n",
" | >>> x\n",
" | array([[3, 1, 7],\n",
" | [2, 0, 3],\n",
" | [8, 5, 9]])\n",
" | \n",
" | max(...)\n",
" | a.max(axis=None, out=None, keepdims=False)\n",
" | \n",
" | Return the maximum along a given axis.\n",
" | \n",
" | Refer to `numpy.amax` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.amax : equivalent function\n",
" | \n",
" | mean(...)\n",
" | a.mean(axis=None, dtype=None, out=None, keepdims=False)\n",
" | \n",
" | Returns the average of the array elements along given axis.\n",
" | \n",
" | Refer to `numpy.mean` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.mean : equivalent function\n",
" | \n",
" | min(...)\n",
" | a.min(axis=None, out=None, keepdims=False)\n",
" | \n",
" | Return the minimum along a given axis.\n",
" | \n",
" | Refer to `numpy.amin` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.amin : equivalent function\n",
" | \n",
" | newbyteorder(...)\n",
" | arr.newbyteorder(new_order='S')\n",
" | \n",
" | Return the array with the same data viewed with a different byte order.\n",
" | \n",
" | Equivalent to::\n",
" | \n",
" | arr.view(arr.dtype.newbytorder(new_order))\n",
" | \n",
" | Changes are also made in all fields and sub-arrays of the array data\n",
" | type.\n",
" | \n",
" | \n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | new_order : string, optional\n",
" | Byte order to force; a value from the byte order specifications\n",
" | below. `new_order` codes can be any of:\n",
" | \n",
" | * 'S' - swap dtype from current to opposite endian\n",
" | * {'<', 'L'} - little endian\n",
" | * {'>', 'B'} - big endian\n",
" | * {'=', 'N'} - native order\n",
" | * {'|', 'I'} - ignore (no change to byte order)\n",
" | \n",
" | The default value ('S') results in swapping the current\n",
" | byte order. The code does a case-insensitive check on the first\n",
" | letter of `new_order` for the alternatives above. For example,\n",
" | any of 'B' or 'b' or 'biggish' are valid to specify big-endian.\n",
" | \n",
" | \n",
" | Returns\n",
" | -------\n",
" | new_arr : array\n",
" | New array object with the dtype reflecting given change to the\n",
" | byte order.\n",
" | \n",
" | nonzero(...)\n",
" | a.nonzero()\n",
" | \n",
" | Return the indices of the elements that are non-zero.\n",
" | \n",
" | Refer to `numpy.nonzero` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.nonzero : equivalent function\n",
" | \n",
" | partition(...)\n",
" | a.partition(kth, axis=-1, kind='introselect', order=None)\n",
" | \n",
" | Rearranges the elements in the array in such a way that the value of the\n",
" | element in kth position is in the position it would be in a sorted array.\n",
" | All elements smaller than the kth element are moved before this element and\n",
" | all equal or greater are moved behind it. The ordering of the elements in\n",
" | the two partitions is undefined.\n",
" | \n",
" | .. versionadded:: 1.8.0\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | kth : int or sequence of ints\n",
" | Element index to partition by. The kth element value will be in its\n",
" | final sorted position and all smaller elements will be moved before it\n",
" | and all equal or greater elements behind it.\n",
" | The order of all elements in the partitions is undefined.\n",
" | If provided with a sequence of kth it will partition all elements\n",
" | indexed by kth of them into their sorted position at once.\n",
" | axis : int, optional\n",
" | Axis along which to sort. Default is -1, which means sort along the\n",
" | last axis.\n",
" | kind : {'introselect'}, optional\n",
" | Selection algorithm. Default is 'introselect'.\n",
" | order : str or list of str, optional\n",
" | When `a` is an array with fields defined, this argument specifies\n",
" | which fields to compare first, second, etc. A single field can\n",
" | be specified as a string, and not all fields need to be specified,\n",
" | but unspecified fields will still be used, in the order in which\n",
" | they come up in the dtype, to break ties.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.partition : Return a parititioned copy of an array.\n",
" | argpartition : Indirect partition.\n",
" | sort : Full sort.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | See ``np.partition`` for notes on the different algorithms.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> a = np.array([3, 4, 2, 1])\n",
" | >>> a.partition(3)\n",
" | >>> a\n",
" | array([2, 1, 3, 4])\n",
" | \n",
" | >>> a.partition((1, 3))\n",
" | array([1, 2, 3, 4])\n",
" | \n",
" | prod(...)\n",
" | a.prod(axis=None, dtype=None, out=None, keepdims=False)\n",
" | \n",
" | Return the product of the array elements over the given axis\n",
" | \n",
" | Refer to `numpy.prod` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.prod : equivalent function\n",
" | \n",
" | ptp(...)\n",
" | a.ptp(axis=None, out=None, keepdims=False)\n",
" | \n",
" | Peak to peak (maximum - minimum) value along a given axis.\n",
" | \n",
" | Refer to `numpy.ptp` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.ptp : equivalent function\n",
" | \n",
" | put(...)\n",
" | a.put(indices, values, mode='raise')\n",
" | \n",
" | Set ``a.flat[n] = values[n]`` for all `n` in indices.\n",
" | \n",
" | Refer to `numpy.put` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.put : equivalent function\n",
" | \n",
" | ravel(...)\n",
" | a.ravel([order])\n",
" | \n",
" | Return a flattened array.\n",
" | \n",
" | Refer to `numpy.ravel` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.ravel : equivalent function\n",
" | \n",
" | ndarray.flat : a flat iterator on the array.\n",
" | \n",
" | repeat(...)\n",
" | a.repeat(repeats, axis=None)\n",
" | \n",
" | Repeat elements of an array.\n",
" | \n",
" | Refer to `numpy.repeat` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.repeat : equivalent function\n",
" | \n",
" | reshape(...)\n",
" | a.reshape(shape, order='C')\n",
" | \n",
" | Returns an array containing the same data with a new shape.\n",
" | \n",
" | Refer to `numpy.reshape` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.reshape : equivalent function\n",
" | \n",
" | Notes\n",
" | -----\n",
" | Unlike the free function `numpy.reshape`, this method on `ndarray` allows\n",
" | the elements of the shape parameter to be passed in as separate arguments.\n",
" | For example, ``a.reshape(10, 11)`` is equivalent to\n",
" | ``a.reshape((10, 11))``.\n",
" | \n",
" | resize(...)\n",
" | a.resize(new_shape, refcheck=True)\n",
" | \n",
" | Change shape and size of array in-place.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | new_shape : tuple of ints, or `n` ints\n",
" | Shape of resized array.\n",
" | refcheck : bool, optional\n",
" | If False, reference count will not be checked. Default is True.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | None\n",
" | \n",
" | Raises\n",
" | ------\n",
" | ValueError\n",
" | If `a` does not own its own data or references or views to it exist,\n",
" | and the data memory must be changed.\n",
" | PyPy only: will always raise if the data memory must be changed, since\n",
" | there is no reliable way to determine if references or views to it\n",
" | exist.\n",
" | \n",
" | SystemError\n",
" | If the `order` keyword argument is specified. This behaviour is a\n",
" | bug in NumPy.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | resize : Return a new array with the specified shape.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | This reallocates space for the data area if necessary.\n",
" | \n",
" | Only contiguous arrays (data elements consecutive in memory) can be\n",
" | resized.\n",
" | \n",
" | The purpose of the reference count check is to make sure you\n",
" | do not use this array as a buffer for another Python object and then\n",
" | reallocate the memory. However, reference counts can increase in\n",
" | other ways so if you are sure that you have not shared the memory\n",
" | for this array with another Python object, then you may safely set\n",
" | `refcheck` to False.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | Shrinking an array: array is flattened (in the order that the data are\n",
" | stored in memory), resized, and reshaped:\n",
" | \n",
" | >>> a = np.array([[0, 1], [2, 3]], order='C')\n",
" | >>> a.resize((2, 1))\n",
" | >>> a\n",
" | array([[0],\n",
" | [1]])\n",
" | \n",
" | >>> a = np.array([[0, 1], [2, 3]], order='F')\n",
" | >>> a.resize((2, 1))\n",
" | >>> a\n",
" | array([[0],\n",
" | [2]])\n",
" | \n",
" | Enlarging an array: as above, but missing entries are filled with zeros:\n",
" | \n",
" | >>> b = np.array([[0, 1], [2, 3]])\n",
" | >>> b.resize(2, 3) # new_shape parameter doesn't have to be a tuple\n",
" | >>> b\n",
" | array([[0, 1, 2],\n",
" | [3, 0, 0]])\n",
" | \n",
" | Referencing an array prevents resizing...\n",
" | \n",
" | >>> c = a\n",
" | >>> a.resize((1, 1))\n",
" | Traceback (most recent call last):\n",
" | ...\n",
" | ValueError: cannot resize an array that has been referenced ...\n",
" | \n",
" | Unless `refcheck` is False:\n",
" | \n",
" | >>> a.resize((1, 1), refcheck=False)\n",
" | >>> a\n",
" | array([[0]])\n",
" | >>> c\n",
" | array([[0]])\n",
" | \n",
" | round(...)\n",
" | a.round(decimals=0, out=None)\n",
" | \n",
" | Return `a` with each element rounded to the given number of decimals.\n",
" | \n",
" | Refer to `numpy.around` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.around : equivalent function\n",
" | \n",
" | searchsorted(...)\n",
" | a.searchsorted(v, side='left', sorter=None)\n",
" | \n",
" | Find indices where elements of v should be inserted in a to maintain order.\n",
" | \n",
" | For full documentation, see `numpy.searchsorted`\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.searchsorted : equivalent function\n",
" | \n",
" | setfield(...)\n",
" | a.setfield(val, dtype, offset=0)\n",
" | \n",
" | Put a value into a specified place in a field defined by a data-type.\n",
" | \n",
" | Place `val` into `a`'s field defined by `dtype` and beginning `offset`\n",
" | bytes into the field.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | val : object\n",
" | Value to be placed in field.\n",
" | dtype : dtype object\n",
" | Data-type of the field in which to place `val`.\n",
" | offset : int, optional\n",
" | The number of bytes into the field at which to place `val`.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | None\n",
" | \n",
" | See Also\n",
" | --------\n",
" | getfield\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.eye(3)\n",
" | >>> x.getfield(np.float64)\n",
" | array([[ 1., 0., 0.],\n",
" | [ 0., 1., 0.],\n",
" | [ 0., 0., 1.]])\n",
" | >>> x.setfield(3, np.int32)\n",
" | >>> x.getfield(np.int32)\n",
" | array([[3, 3, 3],\n",
" | [3, 3, 3],\n",
" | [3, 3, 3]])\n",
" | >>> x\n",
" | array([[ 1.00000000e+000, 1.48219694e-323, 1.48219694e-323],\n",
" | [ 1.48219694e-323, 1.00000000e+000, 1.48219694e-323],\n",
" | [ 1.48219694e-323, 1.48219694e-323, 1.00000000e+000]])\n",
" | >>> x.setfield(np.eye(3), np.int32)\n",
" | >>> x\n",
" | array([[ 1., 0., 0.],\n",
" | [ 0., 1., 0.],\n",
" | [ 0., 0., 1.]])\n",
" | \n",
" | setflags(...)\n",
" | a.setflags(write=None, align=None, uic=None)\n",
" | \n",
" | Set array flags WRITEABLE, ALIGNED, (WRITEBACKIFCOPY and UPDATEIFCOPY),\n",
" | respectively.\n",
" | \n",
" | These Boolean-valued flags affect how numpy interprets the memory\n",
" | area used by `a` (see Notes below). The ALIGNED flag can only\n",
" | be set to True if the data is actually aligned according to the type.\n",
" | The WRITEBACKIFCOPY and (deprecated) UPDATEIFCOPY flags can never be set\n",
" | to True. The flag WRITEABLE can only be set to True if the array owns its\n",
" | own memory, or the ultimate owner of the memory exposes a writeable buffer\n",
" | interface, or is a string. (The exception for string is made so that\n",
" | unpickling can be done without copying memory.)\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | write : bool, optional\n",
" | Describes whether or not `a` can be written to.\n",
" | align : bool, optional\n",
" | Describes whether or not `a` is aligned properly for its type.\n",
" | uic : bool, optional\n",
" | Describes whether or not `a` is a copy of another \"base\" array.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | Array flags provide information about how the memory area used\n",
" | for the array is to be interpreted. There are 7 Boolean flags\n",
" | in use, only four of which can be changed by the user:\n",
" | WRITEBACKIFCOPY, UPDATEIFCOPY, WRITEABLE, and ALIGNED.\n",
" | \n",
" | WRITEABLE (W) the data area can be written to;\n",
" | \n",
" | ALIGNED (A) the data and strides are aligned appropriately for the hardware\n",
" | (as determined by the compiler);\n",
" | \n",
" | UPDATEIFCOPY (U) (deprecated), replaced by WRITEBACKIFCOPY;\n",
" | \n",
" | WRITEBACKIFCOPY (X) this array is a copy of some other array (referenced\n",
" | by .base). When the C-API function PyArray_ResolveWritebackIfCopy is\n",
" | called, the base array will be updated with the contents of this array.\n",
" | \n",
" | All flags can be accessed using the single (upper case) letter as well\n",
" | as the full name.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> y\n",
" | array([[3, 1, 7],\n",
" | [2, 0, 0],\n",
" | [8, 5, 9]])\n",
" | >>> y.flags\n",
" | C_CONTIGUOUS : True\n",
" | F_CONTIGUOUS : False\n",
" | OWNDATA : True\n",
" | WRITEABLE : True\n",
" | ALIGNED : True\n",
" | WRITEBACKIFCOPY : False\n",
" | UPDATEIFCOPY : False\n",
" | >>> y.setflags(write=0, align=0)\n",
" | >>> y.flags\n",
" | C_CONTIGUOUS : True\n",
" | F_CONTIGUOUS : False\n",
" | OWNDATA : True\n",
" | WRITEABLE : False\n",
" | ALIGNED : False\n",
" | WRITEBACKIFCOPY : False\n",
" | UPDATEIFCOPY : False\n",
" | >>> y.setflags(uic=1)\n",
" | Traceback (most recent call last):\n",
" | File \"\", line 1, in \n",
" | ValueError: cannot set WRITEBACKIFCOPY flag to True\n",
" | \n",
" | sort(...)\n",
" | a.sort(axis=-1, kind='quicksort', order=None)\n",
" | \n",
" | Sort an array, in-place.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | axis : int, optional\n",
" | Axis along which to sort. Default is -1, which means sort along the\n",
" | last axis.\n",
" | kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, optional\n",
" | Sorting algorithm. Default is 'quicksort'.\n",
" | order : str or list of str, optional\n",
" | When `a` is an array with fields defined, this argument specifies\n",
" | which fields to compare first, second, etc. A single field can\n",
" | be specified as a string, and not all fields need be specified,\n",
" | but unspecified fields will still be used, in the order in which\n",
" | they come up in the dtype, to break ties.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.sort : Return a sorted copy of an array.\n",
" | argsort : Indirect sort.\n",
" | lexsort : Indirect stable sort on multiple keys.\n",
" | searchsorted : Find elements in sorted array.\n",
" | partition: Partial sort.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | See ``sort`` for notes on the different sorting algorithms.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> a = np.array([[1,4], [3,1]])\n",
" | >>> a.sort(axis=1)\n",
" | >>> a\n",
" | array([[1, 4],\n",
" | [1, 3]])\n",
" | >>> a.sort(axis=0)\n",
" | >>> a\n",
" | array([[1, 3],\n",
" | [1, 4]])\n",
" | \n",
" | Use the `order` keyword to specify a field to use when sorting a\n",
" | structured array:\n",
" | \n",
" | >>> a = np.array([('a', 2), ('c', 1)], dtype=[('x', 'S1'), ('y', int)])\n",
" | >>> a.sort(order='y')\n",
" | >>> a\n",
" | array([('c', 1), ('a', 2)],\n",
" | dtype=[('x', '|S1'), ('y', '>> x = np.array([[0, 1], [2, 3]])\n",
" | >>> x.tobytes()\n",
" | b'\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x03\\x00\\x00\\x00'\n",
" | >>> x.tobytes('C') == x.tobytes()\n",
" | True\n",
" | >>> x.tobytes('F')\n",
" | b'\\x00\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x03\\x00\\x00\\x00'\n",
" | \n",
" | tofile(...)\n",
" | a.tofile(fid, sep=\"\", format=\"%s\")\n",
" | \n",
" | Write array to a file as text or binary (default).\n",
" | \n",
" | Data is always written in 'C' order, independent of the order of `a`.\n",
" | The data produced by this method can be recovered using the function\n",
" | fromfile().\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | fid : file or str\n",
" | An open file object, or a string containing a filename.\n",
" | sep : str\n",
" | Separator between array items for text output.\n",
" | If \"\" (empty), a binary file is written, equivalent to\n",
" | ``file.write(a.tobytes())``.\n",
" | format : str\n",
" | Format string for text file output.\n",
" | Each entry in the array is formatted to text by first converting\n",
" | it to the closest Python type, and then using \"format\" % item.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | This is a convenience function for quick storage of array data.\n",
" | Information on endianness and precision is lost, so this method is not a\n",
" | good choice for files intended to archive data or transport data between\n",
" | machines with different endianness. Some of these problems can be overcome\n",
" | by outputting the data as text files, at the expense of speed and file\n",
" | size.\n",
" | \n",
" | When fid is a file object, array contents are directly written to the\n",
" | file, bypassing the file object's ``write`` method. As a result, tofile\n",
" | cannot be used with files objects supporting compression (e.g., GzipFile)\n",
" | or file-like objects that do not support ``fileno()`` (e.g., BytesIO).\n",
" | \n",
" | tolist(...)\n",
" | a.tolist()\n",
" | \n",
" | Return the array as a (possibly nested) list.\n",
" | \n",
" | Return a copy of the array data as a (nested) Python list.\n",
" | Data items are converted to the nearest compatible Python type.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | none\n",
" | \n",
" | Returns\n",
" | -------\n",
" | y : list\n",
" | The possibly nested list of array elements.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | The array may be recreated, ``a = np.array(a.tolist())``.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> a = np.array([1, 2])\n",
" | >>> a.tolist()\n",
" | [1, 2]\n",
" | >>> a = np.array([[1, 2], [3, 4]])\n",
" | >>> list(a)\n",
" | [array([1, 2]), array([3, 4])]\n",
" | >>> a.tolist()\n",
" | [[1, 2], [3, 4]]\n",
" | \n",
" | tostring(...)\n",
" | a.tostring(order='C')\n",
" | \n",
" | Construct Python bytes containing the raw data bytes in the array.\n",
" | \n",
" | Constructs Python bytes showing a copy of the raw contents of\n",
" | data memory. The bytes object can be produced in either 'C' or 'Fortran',\n",
" | or 'Any' order (the default is 'C'-order). 'Any' order means C-order\n",
" | unless the F_CONTIGUOUS flag in the array is set, in which case it\n",
" | means 'Fortran' order.\n",
" | \n",
" | This function is a compatibility alias for tobytes. Despite its name it returns bytes not strings.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | order : {'C', 'F', None}, optional\n",
" | Order of the data for multidimensional arrays:\n",
" | C, Fortran, or the same as for the original array.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | s : bytes\n",
" | Python bytes exhibiting a copy of `a`'s raw data.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.array([[0, 1], [2, 3]])\n",
" | >>> x.tobytes()\n",
" | b'\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x03\\x00\\x00\\x00'\n",
" | >>> x.tobytes('C') == x.tobytes()\n",
" | True\n",
" | >>> x.tobytes('F')\n",
" | b'\\x00\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x03\\x00\\x00\\x00'\n",
" | \n",
" | trace(...)\n",
" | a.trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)\n",
" | \n",
" | Return the sum along diagonals of the array.\n",
" | \n",
" | Refer to `numpy.trace` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.trace : equivalent function\n",
" | \n",
" | transpose(...)\n",
" | a.transpose(*axes)\n",
" | \n",
" | Returns a view of the array with axes transposed.\n",
" | \n",
" | For a 1-D array, this has no effect. (To change between column and\n",
" | row vectors, first cast the 1-D array into a matrix object.)\n",
" | For a 2-D array, this is the usual matrix transpose.\n",
" | For an n-D array, if axes are given, their order indicates how the\n",
" | axes are permuted (see Examples). If axes are not provided and\n",
" | ``a.shape = (i[0], i[1], ... i[n-2], i[n-1])``, then\n",
" | ``a.transpose().shape = (i[n-1], i[n-2], ... i[1], i[0])``.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | axes : None, tuple of ints, or `n` ints\n",
" | \n",
" | * None or no argument: reverses the order of the axes.\n",
" | \n",
" | * tuple of ints: `i` in the `j`-th place in the tuple means `a`'s\n",
" | `i`-th axis becomes `a.transpose()`'s `j`-th axis.\n",
" | \n",
" | * `n` ints: same as an n-tuple of the same ints (this form is\n",
" | intended simply as a \"convenience\" alternative to the tuple form)\n",
" | \n",
" | Returns\n",
" | -------\n",
" | out : ndarray\n",
" | View of `a`, with axes suitably permuted.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | ndarray.T : Array property returning the array transposed.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> a = np.array([[1, 2], [3, 4]])\n",
" | >>> a\n",
" | array([[1, 2],\n",
" | [3, 4]])\n",
" | >>> a.transpose()\n",
" | array([[1, 3],\n",
" | [2, 4]])\n",
" | >>> a.transpose((1, 0))\n",
" | array([[1, 3],\n",
" | [2, 4]])\n",
" | >>> a.transpose(1, 0)\n",
" | array([[1, 3],\n",
" | [2, 4]])\n",
" | \n",
" | var(...)\n",
" | a.var(axis=None, dtype=None, out=None, ddof=0, keepdims=False)\n",
" | \n",
" | Returns the variance of the array elements, along given axis.\n",
" | \n",
" | Refer to `numpy.var` for full documentation.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.var : equivalent function\n",
" | \n",
" | view(...)\n",
" | a.view(dtype=None, type=None)\n",
" | \n",
" | New view of array with the same data.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | dtype : data-type or ndarray sub-class, optional\n",
" | Data-type descriptor of the returned view, e.g., float32 or int16. The\n",
" | default, None, results in the view having the same data-type as `a`.\n",
" | This argument can also be specified as an ndarray sub-class, which\n",
" | then specifies the type of the returned object (this is equivalent to\n",
" | setting the ``type`` parameter).\n",
" | type : Python type, optional\n",
" | Type of the returned view, e.g., ndarray or matrix. Again, the\n",
" | default None results in type preservation.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | ``a.view()`` is used two different ways:\n",
" | \n",
" | ``a.view(some_dtype)`` or ``a.view(dtype=some_dtype)`` constructs a view\n",
" | of the array's memory with a different data-type. This can cause a\n",
" | reinterpretation of the bytes of memory.\n",
" | \n",
" | ``a.view(ndarray_subclass)`` or ``a.view(type=ndarray_subclass)`` just\n",
" | returns an instance of `ndarray_subclass` that looks at the same array\n",
" | (same shape, dtype, etc.) This does not cause a reinterpretation of the\n",
" | memory.\n",
" | \n",
" | For ``a.view(some_dtype)``, if ``some_dtype`` has a different number of\n",
" | bytes per entry than the previous dtype (for example, converting a\n",
" | regular array to a structured array), then the behavior of the view\n",
" | cannot be predicted just from the superficial appearance of ``a`` (shown\n",
" | by ``print(a)``). It also depends on exactly how ``a`` is stored in\n",
" | memory. Therefore if ``a`` is C-ordered versus fortran-ordered, versus\n",
" | defined as a slice or transpose, etc., the view may give different\n",
" | results.\n",
" | \n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])\n",
" | \n",
" | Viewing array data using a different type and dtype:\n",
" | \n",
" | >>> y = x.view(dtype=np.int16, type=np.matrix)\n",
" | >>> y\n",
" | matrix([[513]], dtype=int16)\n",
" | >>> print(type(y))\n",
" | \n",
" | \n",
" | Creating a view on a structured array so it can be used in calculations\n",
" | \n",
" | >>> x = np.array([(1, 2),(3,4)], dtype=[('a', np.int8), ('b', np.int8)])\n",
" | >>> xv = x.view(dtype=np.int8).reshape(-1,2)\n",
" | >>> xv\n",
" | array([[1, 2],\n",
" | [3, 4]], dtype=int8)\n",
" | >>> xv.mean(0)\n",
" | array([ 2., 3.])\n",
" | \n",
" | Making changes to the view changes the underlying array\n",
" | \n",
" | >>> xv[0,1] = 20\n",
" | >>> print(x)\n",
" | [(1, 20) (3, 4)]\n",
" | \n",
" | Using a view to convert an array to a recarray:\n",
" | \n",
" | >>> z = x.view(np.recarray)\n",
" | >>> z.a\n",
" | array([1], dtype=int8)\n",
" | \n",
" | Views share data:\n",
" | \n",
" | >>> x[0] = (9, 10)\n",
" | >>> z[0]\n",
" | (9, 10)\n",
" | \n",
" | Views that change the dtype size (bytes per entry) should normally be\n",
" | avoided on arrays defined by slices, transposes, fortran-ordering, etc.:\n",
" | \n",
" | >>> x = np.array([[1,2,3],[4,5,6]], dtype=np.int16)\n",
" | >>> y = x[:, 0:2]\n",
" | >>> y\n",
" | array([[1, 2],\n",
" | [4, 5]], dtype=int16)\n",
" | >>> y.view(dtype=[('width', np.int16), ('length', np.int16)])\n",
" | Traceback (most recent call last):\n",
" | File \"\", line 1, in \n",
" | ValueError: new type not compatible with array.\n",
" | >>> z = y.copy()\n",
" | >>> z.view(dtype=[('width', np.int16), ('length', np.int16)])\n",
" | array([[(1, 2)],\n",
" | [(4, 5)]], dtype=[('width', '>> x = np.array([[1.,2.],[3.,4.]])\n",
" | >>> x\n",
" | array([[ 1., 2.],\n",
" | [ 3., 4.]])\n",
" | >>> x.T\n",
" | array([[ 1., 3.],\n",
" | [ 2., 4.]])\n",
" | >>> x = np.array([1.,2.,3.,4.])\n",
" | >>> x\n",
" | array([ 1., 2., 3., 4.])\n",
" | >>> x.T\n",
" | array([ 1., 2., 3., 4.])\n",
" | \n",
" | __array_finalize__\n",
" | None.\n",
" | \n",
" | __array_interface__\n",
" | Array protocol: Python side.\n",
" | \n",
" | __array_priority__\n",
" | Array priority.\n",
" | \n",
" | __array_struct__\n",
" | Array protocol: C-struct side.\n",
" | \n",
" | base\n",
" | Base object if memory is from some other object.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | The base of an array that owns its memory is None:\n",
" | \n",
" | >>> x = np.array([1,2,3,4])\n",
" | >>> x.base is None\n",
" | True\n",
" | \n",
" | Slicing creates a view, whose memory is shared with x:\n",
" | \n",
" | >>> y = x[2:]\n",
" | >>> y.base is x\n",
" | True\n",
" | \n",
" | ctypes\n",
" | An object to simplify the interaction of the array with the ctypes\n",
" | module.\n",
" | \n",
" | This attribute creates an object that makes it easier to use arrays\n",
" | when calling shared libraries with the ctypes module. The returned\n",
" | object has, among others, data, shape, and strides attributes (see\n",
" | Notes below) which themselves return ctypes objects that can be used\n",
" | as arguments to a shared library.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | None\n",
" | \n",
" | Returns\n",
" | -------\n",
" | c : Python object\n",
" | Possessing attributes data, shape, strides, etc.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.ctypeslib\n",
" | \n",
" | Notes\n",
" | -----\n",
" | Below are the public attributes of this object which were documented\n",
" | in \"Guide to NumPy\" (we have omitted undocumented public attributes,\n",
" | as well as documented private attributes):\n",
" | \n",
" | .. autoattribute:: numpy.core._internal._ctypes.data\n",
" | \n",
" | .. autoattribute:: numpy.core._internal._ctypes.shape\n",
" | \n",
" | .. autoattribute:: numpy.core._internal._ctypes.strides\n",
" | \n",
" | .. automethod:: numpy.core._internal._ctypes.data_as\n",
" | \n",
" | .. automethod:: numpy.core._internal._ctypes.shape_as\n",
" | \n",
" | .. automethod:: numpy.core._internal._ctypes.strides_as\n",
" | \n",
" | If the ctypes module is not available, then the ctypes attribute\n",
" | of array objects still returns something useful, but ctypes objects\n",
" | are not returned and errors may be raised instead. In particular,\n",
" | the object will still have the as parameter attribute which will\n",
" | return an integer equal to the data attribute.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> import ctypes\n",
" | >>> x\n",
" | array([[0, 1],\n",
" | [2, 3]])\n",
" | >>> x.ctypes.data\n",
" | 30439712\n",
" | >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_long))\n",
" | \n",
" | >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_long)).contents\n",
" | c_long(0)\n",
" | >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_longlong)).contents\n",
" | c_longlong(4294967296L)\n",
" | >>> x.ctypes.shape\n",
" | \n",
" | >>> x.ctypes.shape_as(ctypes.c_long)\n",
" | \n",
" | >>> x.ctypes.strides\n",
" | \n",
" | >>> x.ctypes.strides_as(ctypes.c_longlong)\n",
" | \n",
" | \n",
" | data\n",
" | Python buffer object pointing to the start of the array's data.\n",
" | \n",
" | dtype\n",
" | Data-type of the array's elements.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | None\n",
" | \n",
" | Returns\n",
" | -------\n",
" | d : numpy dtype object\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.dtype\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x\n",
" | array([[0, 1],\n",
" | [2, 3]])\n",
" | >>> x.dtype\n",
" | dtype('int32')\n",
" | >>> type(x.dtype)\n",
" | \n",
" | \n",
" | flags\n",
" | Information about the memory layout of the array.\n",
" | \n",
" | Attributes\n",
" | ----------\n",
" | C_CONTIGUOUS (C)\n",
" | The data is in a single, C-style contiguous segment.\n",
" | F_CONTIGUOUS (F)\n",
" | The data is in a single, Fortran-style contiguous segment.\n",
" | OWNDATA (O)\n",
" | The array owns the memory it uses or borrows it from another object.\n",
" | WRITEABLE (W)\n",
" | The data area can be written to. Setting this to False locks\n",
" | the data, making it read-only. A view (slice, etc.) inherits WRITEABLE\n",
" | from its base array at creation time, but a view of a writeable\n",
" | array may be subsequently locked while the base array remains writeable.\n",
" | (The opposite is not true, in that a view of a locked array may not\n",
" | be made writeable. However, currently, locking a base object does not\n",
" | lock any views that already reference it, so under that circumstance it\n",
" | is possible to alter the contents of a locked array via a previously\n",
" | created writeable view onto it.) Attempting to change a non-writeable\n",
" | array raises a RuntimeError exception.\n",
" | ALIGNED (A)\n",
" | The data and all elements are aligned appropriately for the hardware.\n",
" | WRITEBACKIFCOPY (X)\n",
" | This array is a copy of some other array. The C-API function\n",
" | PyArray_ResolveWritebackIfCopy must be called before deallocating\n",
" | to the base array will be updated with the contents of this array.\n",
" | UPDATEIFCOPY (U)\n",
" | (Deprecated, use WRITEBACKIFCOPY) This array is a copy of some other array.\n",
" | When this array is\n",
" | deallocated, the base array will be updated with the contents of\n",
" | this array.\n",
" | FNC\n",
" | F_CONTIGUOUS and not C_CONTIGUOUS.\n",
" | FORC\n",
" | F_CONTIGUOUS or C_CONTIGUOUS (one-segment test).\n",
" | BEHAVED (B)\n",
" | ALIGNED and WRITEABLE.\n",
" | CARRAY (CA)\n",
" | BEHAVED and C_CONTIGUOUS.\n",
" | FARRAY (FA)\n",
" | BEHAVED and F_CONTIGUOUS and not C_CONTIGUOUS.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | The `flags` object can be accessed dictionary-like (as in ``a.flags['WRITEABLE']``),\n",
" | or by using lowercased attribute names (as in ``a.flags.writeable``). Short flag\n",
" | names are only supported in dictionary access.\n",
" | \n",
" | Only the WRITEBACKIFCOPY, UPDATEIFCOPY, WRITEABLE, and ALIGNED flags can be\n",
" | changed by the user, via direct assignment to the attribute or dictionary\n",
" | entry, or by calling `ndarray.setflags`.\n",
" | \n",
" | The array flags cannot be set arbitrarily:\n",
" | \n",
" | - UPDATEIFCOPY can only be set ``False``.\n",
" | - WRITEBACKIFCOPY can only be set ``False``.\n",
" | - ALIGNED can only be set ``True`` if the data is truly aligned.\n",
" | - WRITEABLE can only be set ``True`` if the array owns its own memory\n",
" | or the ultimate owner of the memory exposes a writeable buffer\n",
" | interface or is a string.\n",
" | \n",
" | Arrays can be both C-style and Fortran-style contiguous simultaneously.\n",
" | This is clear for 1-dimensional arrays, but can also be true for higher\n",
" | dimensional arrays.\n",
" | \n",
" | Even for contiguous arrays a stride for a given dimension\n",
" | ``arr.strides[dim]`` may be *arbitrary* if ``arr.shape[dim] == 1``\n",
" | or the array has no elements.\n",
" | It does *not* generally hold that ``self.strides[-1] == self.itemsize``\n",
" | for C-style contiguous arrays or ``self.strides[0] == self.itemsize`` for\n",
" | Fortran-style contiguous arrays is true.\n",
" | \n",
" | flat\n",
" | A 1-D iterator over the array.\n",
" | \n",
" | This is a `numpy.flatiter` instance, which acts similarly to, but is not\n",
" | a subclass of, Python's built-in iterator object.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | flatten : Return a copy of the array collapsed into one dimension.\n",
" | \n",
" | flatiter\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.arange(1, 7).reshape(2, 3)\n",
" | >>> x\n",
" | array([[1, 2, 3],\n",
" | [4, 5, 6]])\n",
" | >>> x.flat[3]\n",
" | 4\n",
" | >>> x.T\n",
" | array([[1, 4],\n",
" | [2, 5],\n",
" | [3, 6]])\n",
" | >>> x.T.flat[3]\n",
" | 5\n",
" | >>> type(x.flat)\n",
" | \n",
" | \n",
" | An assignment example:\n",
" | \n",
" | >>> x.flat = 3; x\n",
" | array([[3, 3, 3],\n",
" | [3, 3, 3]])\n",
" | >>> x.flat[[1,4]] = 1; x\n",
" | array([[3, 1, 3],\n",
" | [3, 1, 3]])\n",
" | \n",
" | imag\n",
" | The imaginary part of the array.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.sqrt([1+0j, 0+1j])\n",
" | >>> x.imag\n",
" | array([ 0. , 0.70710678])\n",
" | >>> x.imag.dtype\n",
" | dtype('float64')\n",
" | \n",
" | itemsize\n",
" | Length of one array element in bytes.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.array([1,2,3], dtype=np.float64)\n",
" | >>> x.itemsize\n",
" | 8\n",
" | >>> x = np.array([1,2,3], dtype=np.complex128)\n",
" | >>> x.itemsize\n",
" | 16\n",
" | \n",
" | nbytes\n",
" | Total bytes consumed by the elements of the array.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | Does not include memory consumed by non-element attributes of the\n",
" | array object.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.zeros((3,5,2), dtype=np.complex128)\n",
" | >>> x.nbytes\n",
" | 480\n",
" | >>> np.prod(x.shape) * x.itemsize\n",
" | 480\n",
" | \n",
" | ndim\n",
" | Number of array dimensions.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.array([1, 2, 3])\n",
" | >>> x.ndim\n",
" | 1\n",
" | >>> y = np.zeros((2, 3, 4))\n",
" | >>> y.ndim\n",
" | 3\n",
" | \n",
" | real\n",
" | The real part of the array.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.sqrt([1+0j, 0+1j])\n",
" | >>> x.real\n",
" | array([ 1. , 0.70710678])\n",
" | >>> x.real.dtype\n",
" | dtype('float64')\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.real : equivalent function\n",
" | \n",
" | shape\n",
" | Tuple of array dimensions.\n",
" | \n",
" | The shape property is usually used to get the current shape of an array,\n",
" | but may also be used to reshape the array in-place by assigning a tuple of\n",
" | array dimensions to it. As with `numpy.reshape`, one of the new shape\n",
" | dimensions can be -1, in which case its value is inferred from the size of\n",
" | the array and the remaining dimensions. Reshaping an array in-place will\n",
" | fail if a copy is required.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.array([1, 2, 3, 4])\n",
" | >>> x.shape\n",
" | (4,)\n",
" | >>> y = np.zeros((2, 3, 4))\n",
" | >>> y.shape\n",
" | (2, 3, 4)\n",
" | >>> y.shape = (3, 8)\n",
" | >>> y\n",
" | array([[ 0., 0., 0., 0., 0., 0., 0., 0.],\n",
" | [ 0., 0., 0., 0., 0., 0., 0., 0.],\n",
" | [ 0., 0., 0., 0., 0., 0., 0., 0.]])\n",
" | >>> y.shape = (3, 6)\n",
" | Traceback (most recent call last):\n",
" | File \"\", line 1, in \n",
" | ValueError: total size of new array must be unchanged\n",
" | >>> np.zeros((4,2))[::2].shape = (-1,)\n",
" | Traceback (most recent call last):\n",
" | File \"\", line 1, in \n",
" | AttributeError: incompatible shape for a non-contiguous array\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.reshape : similar function\n",
" | ndarray.reshape : similar method\n",
" | \n",
" | size\n",
" | Number of elements in the array.\n",
" | \n",
" | Equal to ``np.prod(a.shape)``, i.e., the product of the array's\n",
" | dimensions.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | `a.size` returns a standard arbitrary precision Python integer. This\n",
" | may not be the case with other methods of obtaining the same value\n",
" | (like the suggested ``np.prod(a.shape)``, which returns an instance\n",
" | of ``np.int_``), and may be relevant if the value is used further in\n",
" | calculations that may overflow a fixed size integer type.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> x = np.zeros((3, 5, 2), dtype=np.complex128)\n",
" | >>> x.size\n",
" | 30\n",
" | >>> np.prod(x.shape)\n",
" | 30\n",
" | \n",
" | strides\n",
" | Tuple of bytes to step in each dimension when traversing an array.\n",
" | \n",
" | The byte offset of element ``(i[0], i[1], ..., i[n])`` in an array `a`\n",
" | is::\n",
" | \n",
" | offset = sum(np.array(i) * a.strides)\n",
" | \n",
" | A more detailed explanation of strides can be found in the\n",
" | \"ndarray.rst\" file in the NumPy reference guide.\n",
" | \n",
" | Notes\n",
" | -----\n",
" | Imagine an array of 32-bit integers (each 4 bytes)::\n",
" | \n",
" | x = np.array([[0, 1, 2, 3, 4],\n",
" | [5, 6, 7, 8, 9]], dtype=np.int32)\n",
" | \n",
" | This array is stored in memory as 40 bytes, one after the other\n",
" | (known as a contiguous block of memory). The strides of an array tell\n",
" | us how many bytes we have to skip in memory to move to the next position\n",
" | along a certain axis. For example, we have to skip 4 bytes (1 value) to\n",
" | move to the next column, but 20 bytes (5 values) to get to the same\n",
" | position in the next row. As such, the strides for the array `x` will be\n",
" | ``(20, 4)``.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | numpy.lib.stride_tricks.as_strided\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> y = np.reshape(np.arange(2*3*4), (2,3,4))\n",
" | >>> y\n",
" | array([[[ 0, 1, 2, 3],\n",
" | [ 4, 5, 6, 7],\n",
" | [ 8, 9, 10, 11]],\n",
" | [[12, 13, 14, 15],\n",
" | [16, 17, 18, 19],\n",
" | [20, 21, 22, 23]]])\n",
" | >>> y.strides\n",
" | (48, 16, 4)\n",
" | >>> y[1,1,1]\n",
" | 17\n",
" | >>> offset=sum(y.strides * np.array((1,1,1)))\n",
" | >>> offset/y.itemsize\n",
" | 17\n",
" | \n",
" | >>> x = np.reshape(np.arange(5*6*7*8), (5,6,7,8)).transpose(2,3,1,0)\n",
" | >>> x.strides\n",
" | (32, 4, 224, 1344)\n",
" | >>> i = np.array([3,5,2,2])\n",
" | >>> offset = sum(i * x.strides)\n",
" | >>> x[3,5,2,2]\n",
" | 813\n",
" | >>> offset / x.itemsize\n",
" | 813\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Data and other attributes defined here:\n",
" | \n",
" | __hash__ = None\n",
"\n"
]
}
],
"source": [
"help(np.ndarray) # 文档即教程"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 关于Numpy类型"
]
},
{
"cell_type": "code",
"execution_count": 145,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"numpy.ndarray"
]
},
"execution_count": 145,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(np_weights) # 应该返回numpy的类型"
]
},
{
"cell_type": "code",
"execution_count": 146,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"numpy.ndarray"
]
},
"execution_count": 146,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mixed_list = [1.0, \"is\", True] # 通用类型的list\n",
"type(np.array(mixed_list)) # 转化为numpy array"
]
},
{
"cell_type": "code",
"execution_count": 147,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"array(['1.0', 'is', 'True'], dtype='具有本地索引的应用程序,Jupyter的help菜单速度不够快\n",
"\n",
"- [Dash](https://kapeli.com/dash)\n",
"- [velocity](http://velocity.silverlakesoftware.com/)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 数理统计和线性代数基础"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"##### 数理统计的例子\n",
"- 在大样本数据上计算身高体重指数\n",
"- 把前面5人的例子扩大1000倍\n",
"- 随机产生一个正态分布"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"> [正态分布生成](https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.normal.html?highlight=random%20normal#numpy.random.normal)文档\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"##### 中国成年人身高,体重均值和标准差的参考值 (2015)\n",
"|性别|东北华北|西北|东南|华中|华南|西南|\n",
"|-|-|-|-|-|-|-|\n",
"|身高,体重|均值,标准差|均值,标准差|均值,标准差|均值,标准差|均值,标准差|均值,标准差|\n",
"|男(mm)|1693, 56.6|1684, 53.7|1686, 55,2|1669, 56.3|1650, 57.1|1647, 56.7|\n",
"|女(mm)|1586, 51.8|1575, 51.9|1575, 50.8|1560, 50.7|1549, 49.7|1546, 53.9|\n",
"|男(kg)|64, 8.2|60, 7.6|59, 7.7|57, 6.9|56, 6.9|55, 6.8|\n",
"|女(kg)|55, 7.1|52, 7.1|51, 7.2|50, 6.8|49, 6.5|50, 6.9|\n",
"\n",
"> 选择东南地区成年男性数据:身高:1686, 55.2,体重:59, 7.7"
]
},
{
"cell_type": "code",
"execution_count": 148,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 1.70968916, 52.24683079],\n",
" [ 1.58328235, 55.44822133],\n",
" [ 1.6495744 , 42.18011517],\n",
" ...,\n",
" [ 1.84574057, 62.61678161],\n",
" [ 1.73779399, 53.75894973],\n",
" [ 1.69617327, 55.12759054]])"
]
},
"execution_count": 148,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"height_5k = np.random.normal(1.686, 0.0552, 5000) # 5000身高数据\n",
"weight_5k = np.random.normal(59, 7.7, 5000) # 5000体重数据\n",
"shmale_5k = np.column_stack((height_5k, weight_5k)) # 5000上海男性数据\n",
"shmale_5k # 随机产生一些瘦子和胖子"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"上海男 均值 标准差\n",
"------------ -------- ---------\n",
"身高(米) 1.68475 0.0549343\n",
"体重(公斤) 59.0066 7.79089\n"
]
}
],
"source": [
"shmale_weight = shmale_5k[:,1]\n",
"shmale_height = shmale_5k[:,0]\n",
"shmale_height_mean = np.mean(shmale_height) # 身高均值\n",
"shmale_height_std = np.std(shmale_height) # 身高标准差\n",
"shmale_weight_mean = np.mean(shmale_weight) # 体重均值\n",
"shmale_weight_std = np.std(shmale_weight) # 体重标准差\n",
"from tabulate import tabulate # 格式化成表格样式\n",
"print(tabulate([['身高(米)', shmale_height_mean, shmale_height_std], \n",
" ['体重(公斤)', shmale_weight_mean, shmale_weight_std]], \n",
" headers=['上海男','均值', '标准差']))\n"
]
},
{
"cell_type": "code",
"execution_count": 149,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([21.53342165, 15.81248488, 19.94218316, ..., 19.06582984,\n",
" 17.61357691, 25.66580711])"
]
},
"execution_count": 149,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"shmale_bmi = shmale_weight / shmale_height ** 2 # 计算5000身高体重指数\n",
"shmale_bmi"
]
},
{
"cell_type": "code",
"execution_count": 150,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20.854954078674073 3.074664871185173\n"
]
}
],
"source": [
"print(np.mean(shmale_bmi), np.std(shmale_bmi)) # 上海男性体型分布"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"##### 线性代数例子\n",
"- 解方程组\n",
"\\begin{equation}2x + 3y = 8 \\end{equation}\n",
"\\begin{equation}5x + 2y = 9 \\end{equation}\n",
"\n",
"- 用矩阵的形式表示为\n",
"$$ A = \\begin{bmatrix}2 & 3\\\\5 & 2\\end{bmatrix} \\;\\;\\;\\; \\vec{b} = \\begin{bmatrix}8\\\\9\\end{bmatrix}$$\n",
"\n",
"- 目标是求向量x\n",
"$$ A\\vec{x}= \\vec{b} $$"
]
},
{
"cell_type": "code",
"execution_count": 151,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([[2, 5],\n",
" [3, 2]])"
]
},
"execution_count": 151,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = np.array([[2, 3], [5, 2]]) # 方程组系数矩阵\n",
"a.transpose() # 转置"
]
},
{
"cell_type": "code",
"execution_count": 152,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(2,) (2, 2)\n"
]
},
{
"data": {
"text/plain": [
"array([8, 9])"
]
},
"execution_count": 152,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b = np.array([8, 9])\n",
"print(b.shape, a.shape) # shape不是函数,是tuple\n",
"b.transpose()"
]
},
{
"cell_type": "code",
"execution_count": 153,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" A 0 1\n",
"--- --- ---\n",
" 0 2 3\n",
" 1 5 2\n"
]
}
],
"source": [
"# 矩阵的索引\n",
"print(tabulate([['0', a[0,0], a[0,1]], \n",
" ['1', a[1,0], a[1,1]]], \n",
" headers=['A', '0', '1']))"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
">[矩阵运算](https://docs.scipy.org/doc/numpy/reference/routines.linalg.html)文档\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
""
]
},
{
"cell_type": "code",
"execution_count": 154,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([[-0.18181818, 0.27272727],\n",
" [ 0.45454545, -0.18181818]])"
]
},
"execution_count": 154,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 矩阵求逆\n",
"from numpy.linalg import inv as inv\n",
"a_inv = inv(a)\n",
"a_inv"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"$$ A^{-1}A=\\begin{bmatrix}1 & 0\\\\0 & 1\\end{bmatrix} $$"
]
},
{
"cell_type": "code",
"execution_count": 155,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 1., 0.],\n",
" [-0., 1.]])"
]
},
"execution_count": 155,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.round(a_inv @ a) # 逆矩阵和原矩阵乘来验证求逆, @代表矩阵乘"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"$$ A^{-1}A\\vec{x}=A^{-1}\\vec{b}$$\n",
"\n",
"\n",
"$$ \\begin{bmatrix}1 & 0\\\\0 & 1\\end{bmatrix}\\vec{x}= A^{-1}\\vec{b}$$\n",
"\n",
"\n",
"$$ \\vec{x} = A^{-1}\\vec{b}$$\n"
]
},
{
"cell_type": "code",
"execution_count": 156,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([1., 2.])"
]
},
"execution_count": 156,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = a_inv @ b\n",
"x"
]
},
{
"cell_type": "code",
"execution_count": 157,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([1., 2.])"
]
},
"execution_count": 157,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from numpy.linalg import solve as solve # 引入求解方法\n",
"solve(a, b)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"$$ \\vec{x} = \\begin{bmatrix}1\\\\2\\end{bmatrix} $$\n",
"\n",
"\n",
"$$ x=1 $$\n",
"$$ y=2 $$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# 图形绘制\n",
">图形可视化是非常强大的工具"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"[Hans Rosling](https://en.wikipedia.org/wiki/Hans_Rosling)的[例子](https://www.ted.com/talks/hans_rosling_shows_the_best_stats_you_ve_ever_seen)\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Matplot"
]
},
{
"cell_type": "code",
"execution_count": 158,
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"outputs": [],
"source": [
"from IPython.core.interactiveshell import InteractiveShell\n",
"InteractiveShell.ast_node_interactivity = \"last_expr\""
]
},
{
"cell_type": "code",
"execution_count": 159,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAD8CAYAAABXe05zAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAHrlJREFUeJz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3utqsY6Kr2LY2w76XWE5GTB1tpNBFoJGGMSgMuc7cVAsXN5pTEmg8CRaxbQsdxddAR21WbNlalsLQRq/sZae8C57l8E+pdv4r21/ORG/u9oG1z6uBxnHWOBz621pcA+Y8z3QDKBI6Hyv124Yh1w3J+VMmDiT/sZY34A0oHDuOQxMcZEEwi7t6y17zub9xpj2llrdzutkH3O9iyO/RhkAcMqbF8UzLorquY6KlPZ+k5KSI64jTGtnc91gD8Arzj/jjXGRDmXuwI9CLwQthvIM8YMdV4hvwX4MBS1V1TZWoAvgH7GmBinp3oesMGja/lp22gCvTng378ium4tx1nHDuAC5x0MjQi8CLaJwAuAPYwxXYwx9Qj8B/VR7Vf+347zsxLjrAFjzAigzFrrmueX87VfAzZaa6eWu+oj4Kd3hvyiXG0fAbc4j81Q4Iizli+Ai4wxzZ13blzkbKsVJ7GOytTsc6wWXpWdTaAFUkrgf53bgQkEXp1NA57i/waBrgXWE+jfrQKuKHc/yQT6fRnACz/dpjY/qrMWZ/+bnfWsA572+FqGAUuPcT8hXUs1n1+NgbnOY7IBeKDc/Yx09s8AHq7tx+Mk1hIPbCbwYtlXBP6ynCseE6eGswm0AtYAKc7HSALvrlpA4LeDBUALZ38DvOjUvBZILndftwFbnI9bXb6Ots5jl0vgBeMsAi8W1+hzTJOTIiIeo8lJERGPUXCLiHiMgltExGMU3CIiHqPgFhHxGAW3iIjHKLhFRDxGwS0i4jH/HwBs1kgszo//AAAAAElFTkSuQmCC\n",
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"import matplotlib.pyplot as plt \n",
"year = [1950, 1970, 1990, 2010] # 世界人口数据\n",
"pop = [2.519, 3.692, 5.263, 6.972] \n",
"plt.plot(year, pop) # 折线图\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAA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ero2ITRFxHvDm6r7aHZOI2ApsA+4HXpeZh6ARijReoULrY1CbY9NmH62saR+9Cu4bgI9ExF4af368VI0fAs7NzG3AHwJfrNb0llujq8vlMK162QS8DfhA9fG3IuIKyuwFgIj4FeDHmbm4BlvXXlr1cQmwAGwGzgP+KCLOp759QOtePkPjh38S+CTwdeBlatZLRLwa+Cfgo5n5/EpTlxnLFcbXVQd9tNzFMmPH3UdP/uuyzHycxlICEfFG4N3V+IvAi9X23oh4isYr14PAOU27OAeYWc+aW2nVC42av5aZz1b3/SuN9cvPU14vi67jp6+2oabHZYU+3g/cmZlHgMMR8d/ACI1XQs1/XdSiD1jxZ+Vl4A8W50XE14EngB9Qk2MSEf00wu4Lmbm7Gv5+RJydmYeqpZDD1fhBlj8GB4HLlozf0826l+qwj1Za9XdcevKKOyLOqj6eBPwJ8Knq86GI6Ku2zwfeQONE2CHghYi4tDpD/iHgn3tR+1KtegEmgDdFxCnVmuo7gEcL7WVx7L001uaAo38i1q6XFfr4LnB5dQXDqTROgj1O4wTgGyLivIg4mcYvqDvWv/KftcLPyilVD0TEO4GXM7M2z6/qa/8j8Fhm/nXTXXcAi1eGXN9U2x3Ah6pjcynwf1UvE8CVEXF6deXGldXYujiOPlpZ2+fYOpyVvYXGEsgRGr91fg+4kcbZ2W8Df8FP3wj0HuARGut3DwC/2bSfERrrfU8Bf7f4mPW8ddJLNf+DVT8PA58ovJfLgPuW2U9Pe+nw+fVq4MvVMXkUGGvaz9XV/KeAP17v43EcvWwFpmicLPt3Gv+yXC2OSVXD22gsBTwE7K9uV9O4uupuGn8d3A2cUc0P4O+rmg8AI037ugF4srp9uOZ9/Fx17J6nccL4II2TxWv6HPOdk5JUGN85KUmFMbglqTAGtyQVxuCWpMIY3JJUGINbkgpjcEtSYQxuSSrM/wP/YSAyWkzrXwAAAABJRU5ErkJggg==\n",
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.scatter(year, pop) # 散点图\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 160,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEWCAYAAABliCz2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3XeYVPX5/vH3Q5cmvbN0RETqUjQWFIm9iwqWRKOkWFDURGMSk9gSf0osWCAxxqigoGJNVEQBGyi9s7BLW3qHBbY/vz/mkMx3w8Kw7uy0+3VdezFz5pw5z2dnuffsZ848x9wdERFJfpViXYCIiFQMBb6ISIpQ4IuIpAgFvohIilDgi4ikCAW+iEiKUOBLQjKzqWZ2UymPtTUzN7MqFV3X4Ryu5gi2TTOzHDOrXN51SepQ4IvEITNbbWZnHbzv7mvdvba7F8WyLklscXUEJHIkZmaAxboOkUSkI3yJGjO7wczeD7u/0swmhN1fZ2Y9g9snm9l3ZrY7+PfksPWmmtnDZvYVsB9oX2I/lc3scTPbZmZZwPlHqGu1md1nZkvMbKeZvWRmNcIevzmodYeZvWdmLcIeczO73cyygv39PzOrFDz2ezN7NWzdUqeWzKyDmX1mZtuD53nNzOoFj70CpAHvB9M4vyz5XGbWIqhtR1DrzWHP/Xszm2Bm/zSzvWa22MzSD/c9kdSgwJdomgacamaVzKw5UBX4AYCZtQdqAwvMrAHwIfA00BAYBXxoZg3Dnus6YDhQB1hTYj83AxcAvYB04IoIarsGOBvoAHQGfhPUdSbwKHAl0DzY1+sltr002E9v4GLgxgj2V5IF+2kBHA+0Bn4P4O7XAWuBC4NpnMcOsf14IDvY/grgETMbFPb4RUHd9YD3gNFlqFGSjAJfosbds4C9QE/gdOBjYL2ZdQnuf+HuxYSOyFe4+yvuXuju44FlwIVhT/cPd18cPF5QYldXAk+6+zp330EoSI9kdNj6DwNDg+XXA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RPyXUWjcuXpOghlMITVksAOYFX+cROlttCqG/RqYADYL1DXg2qHkhkB72XDcCK4OvG+J8HM2C124PoTfSswm9iV6uP2NqrSAikiISakpHRETKToEvIpIiFPgiIilCgS8ikiIU+CIiKUKBLyKSIhT4IuXo4AcAReKRAl9Slpk9eLBPeXD/YTO73czuMbPvLNRf/Q9hj79jZrOD/ubDw5bnmNkfzWwmofbCInFJgS+p7EWCj7kHLQiuBjYTas3RD+gJ9DGz04L1b3T3PoQ+kXq7mTUMltci1Iu+v7t/WZEDEDkaCdU8TaQ8uftqM9tuZr2ApsBcQheh+GFwG0JtFToR6i1/u5ldGixvHSzfTqiT5lsVWbtIWSjwJdX9DfgxoV4mfwcGAY+6+5jwlSx0KcCzgJPcfb+ZTQVqBA/nuntRRRUsUlaa0pFUN4nQlZD6Euqm+DFwY9DHHDNrGXSePBbYGYR9F0IdM0USio7wJaW5e76ZfQ7sCo7SPzGz44FvQh1uySHUvfQj4GdmtoBQt8kZsapZpKzULVNSWvBm7RxgiLuviHU9ItGkKR1JWWbWlVCv9CkKe0kFOsIXEUkROsIXEUkRCnwRkRShwBcRSREKfBGRFKHAFxFJEf8f7WvU7I2rQAMAAAAASUVORK5CYII=\n",
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot(year, pop)\n",
"plt.xlabel(\"year\") # 不能使用Unicode, \"年\"\n",
"plt.ylabel(\"population\") # 坐标轴标注\n",
"plt.title(\"world population\") # 标题\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAEWCAYAAACT7WsrAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGx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MEfanA8cPsztaWHcDl4dU0fQlOkm4iRYefOcn/lcywfszsKqDJ3VPm5yvc94+Aje7+nbhZzwItVyjdFVfbs8Anws9lDnAgbMvvgKvNbHB4BdHV4bQOcQbtiNK2P18ddea+I74I/vKsIjiRUw58Erif4CqBd4F/4P27zG8F1hP0t5YAN8Rtp4igf3Yr8P2WdVK1LeHyHw/bsw74Vidvy3xg+Qm206naAvQD/iP8XDYAD8Zt5/pw+a3A/0rxdowB3iE4kfpfwOgU+0zmEXSnlAKrw6/rCa7yW0pw1LMUyAqXN4KHm20F1gJFcdu6F9gSft2T4u0YHn52BwkuJignuJCgTX++NCyHiIhE6vLdTSIicuYUEiIiEkkhISIikRQSIiISSSEhIiKRFBIiIhJJISGSZC03dYqkIoWEyGkws6+3jPMfvv+Gmd1nZg+a2dsWPJ/ga3HznzGzleHzARbHTT9kZn9nZm8RDLUtkpIUEiKn50eEQySEw1fcBuwmGNblAmAGcJ6ZXRIuf6+7n0dwZ/J9ZpYdTu9L8CyH2e7+ekc2QOR0dPkB/kTakrtvN7MaM5sJDANWETz45erwNQTDcUwgeDbDfWZ2czh9ZDi9hmB02Kc6snaRM6GQEDl9PwTuJhg758fAFcA33f0H8QtZ8JjPK4G57n7EzJYBvcPZx9y9uaMKFjlT6m4SOX1PEzyx7HyCUUJ/B9wbPgcAM8sPR1QdCOwLA2IywSiwIp2KjiRETpO7N5jZK8D+8GjgJTObArwZjPbMIYJReV8E/tzMSglGUV2erJpFzpRGgRU5TeEJ6xLgw+6+Odn1iLQndTeJnAYzm0rwrIGlCgjpDnQkISIikXQkISIikRQSIiISSSEhIiKRFBIiIhJJISEiIpH+B4VtSHFfyYkdAAAAAElFTkSuQmCC\n",
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot(year, pop)\n",
"plt.xlabel(\"year\")\n",
"plt.ylabel(\"population\")\n",
"plt.title(\"world population\")\n",
"plt.yticks([0,2,4,6,8,10],\n",
" [\"0\",\"2B\",\"4B\",\"6B\",\"8B\",\"10B\"]) # 坐标轴刻度\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 161,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAEWCAYAAACT7WsrAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3Xl4neV55/HvLcmyrF2ytVmyLK8YbLxghS0EaEjJRgJpQoGQlbZ05moKSRsyZCZzpWkmTZtm0rSTzDS0SchCSNMktU2xWUIwBAgGG8u2bAPeF+2WZMu2bGu754/3lX1Q/NrHQtI5R/p9rkuXznnX+/GR9dO7PY+5OyIiImeTlugCREQkeSkkREQkkkJCREQiKSRERCSSQkJERCIpJEREJJJCQiYUM1trZn8cMa/GzNzMMsa6rnM5V81xrFttZsfMLH2k65KJQSEhMo6Y2V4ze8fge3ff7+657t6fyLokdSXVX0wio8XMDLBE1yGSanQkIUnHzD5pZo/EvN9pZj+LeX/AzJaGr682s5fN7Ej4/eqY5daa2VfM7HmgG5g9ZD/pZvZ1MztkZruB956nrr1m9nkz22ZmnWb2fTPLipn/J2GtHWa2ysymx8xzM7vHzHaH+/t7M0sL5/2Vmf04ZtnI015mNsfMfm1m7eF2HjKzwnDej4Bq4JHwFNPnhm7LzKaHtXWEtf5JzLb/ysx+ZmY/NLOjZrbVzGrP9W8i459CQpLRM8DbzCzNzCqAScBbAcxsNpALbDazYuBR4J+AqcA3gEfNbGrMtj4K3A3kAfuG7OdPgJuAZUAt8KE4arsTeCcwB5gPfCGs6+3AV4E/BCrCff10yLofCPdzGXAzcFcc+xvKwv1MBy4GZgB/BeDuHwX2A+8LTzF97SzrPwwcDNf/EPA3ZnZDzPz3h3UX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YqJpFhku9wIpcoPCC9SvAre6+I9H1iIwmnW4SuQBmdgnBWANPKSBkItCRhIiIRNKRhIiIRFJIiIhIJIWEiIhEUkiIiEgkhYSIiET6/zXhCPAVsC0cAAAAAElFTkSuQmCC\n",
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot(year, pop)\n",
"plt.fill_between(year,pop,0,color='lightblue') # 填充色\n",
"plt.xlabel(\"year\")\n",
"plt.ylabel(\"population\")\n",
"plt.title(\"world population\")\n",
"plt.yticks([0,2,4,6,8,10],\n",
" [\"0\",\"2B\",\"4B\",\"6B\",\"8B\",\"10B\"])\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 直方图\n",
"\n",
"- 数据分布的可视化\n",
"- 数据分布\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"> [直方图](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.hist.html?highlight=hist#matplotlib.pyplot.hist)文档\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
""
]
},
{
"cell_type": "code",
"execution_count": 162,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAEB9JREFUeJzt3V2sXWWdx/Hvz7a+jG8k9mRs+uJxAplEjQKeMBoSQ0AnKAQmEZOS+ILRNDEyYsbEgBcYuZIbNQ5GUoGxKCMYUFOxjoNBolxQOa0FhOKkMUw4gUkrKNhRMdX/XJx1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qkOEuSQ36P2vzacDtDMnoAAAAAElFTkSuQmCC\n",
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"values = [0,0.6,1.4,1.6,2.2,2.5,2.6,3.2,3.5,3.9,4.2,6] \n",
"plt.hist(values, bins=4) # 分布区间数目\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 163,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAEjxJREFUeJzt3W2MXNd93/Hvr5TlpzSmHlaqStJdpSZSB0EtGwuFrYvCFZ1AD0GoAmYgN6kYgQDzQmnjOkDN5o2Toi8ooI1qo4UANnRNFa4jVbFLIhLSCLSMpC+keCUr8gNjiFYZcU2W3ESUHFewE8X/vpiz8IZacu9yZzni2e8HGMy9556Z+c/F5W8Pz9yZm6pCktSvvzHpAiRJa8ugl6TOGfSS1DmDXpI6Z9BLUucMeknqnEEvSZ0z6CWpcwa9JHXuikkXAHDttdfW9PT0pMuQpMvK008//adVNbVcvzdE0E9PTzM7OzvpMiTpspLkT4b0c+pGkjpn0EtS5wx6SeqcQS9JnTPoJalzBr0kdc6gl6TODQr6JP8qydeSfDXJZ5O8JcmNSZ5K8nySh5Jc2fq+ua0fa9un1/INSJIubNmgT7IJ+JfATFX9OLABuAu4D7i/qrYCZ4Hd7SG7gbNV9S7g/tZPkjQhQ78ZewXw1iR/CbwNOAXcAvyztv0g8GvAA8COtgzwCPCfkqS8CrkmZHrvoxf92OP77hhjJdJkLDuir6pvAf8eeJFRwL8CPA28XFWvtW5zwKa2vAk40R77Wut/zXjLliQNNWTq5ipG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O72vIu4NAEa5mIhYBr/inw1fP1vdwlCXAAOFpVv7Fo07o5Ds63D9bLcZBkKsnGtvxW4IOMPqd4AvhQ69b1MXAhl/0XppJ8FvgAo1+pOw18HPifwMPAO4EXgZ1V1e2HlefZBx9g9N/1Ao4Dv7gwX92bJP8I+APgK8D3W/OvMpqjXhfHwQX2wYdZB8dBkr/P6MPWDYwGsA9X1b9N8iOMrolxNfBl4Oer6nuTq3QyLvuglyRdWK9TN5KkxqCXpM4Z9JLUOYNekjpn0EtS5wx6SeqcQS9JnTPoJalz/x+YiztfL9jSKgAAAABJRU5ErkJggg==\n",
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.hist(shmale_bmi, bins=20) # 几乎是一个钟形曲线\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": []
}
],
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
},
"livereveal": {
"scroll": true
},
"rise": {
"enable_chalkboard": true
}
},
"nbformat": 4,
"nbformat_minor": 2
}