├── .github └── workflows │ └── jekyll-gh-pages.yml ├── .gitignore ├── .vscode └── settings.json ├── README.md ├── docs ├── .Rhistory ├── 0-前言.md ├── 00-内容提要.md ├── 01-introduction.md ├── 02-base.md ├── 03-data-structure.md ├── 04-control-flow.md ├── 05-function-and-module.md ├── 06-numpy.md ├── 07-matplotlib.ipynb ├── 07-matplotlib.md ├── 08-pandas-intro.md ├── 09-markdown.md ├── 10-data-import.md ├── 11-toolbox.md ├── 12-advanced-pandas.assets │ ├── image-20191230003925736.png │ ├── image-20191230004055880.png │ ├── image-20191230004143103.png │ ├── image-20191230004245577.png │ ├── image-20191230004347306.png │ ├── image-20191230004432888.png │ ├── image-20191230004515958.png │ ├── image-20191230004552654.png │ ├── image-20191230004636247.png │ ├── image-20191230004751906.png │ ├── image-20191230004830637.png │ ├── image-20191230004907721.png │ └── image-20191230004953542.png ├── 12-advanced-pandas.md ├── 12-pandas-vis.ipynb ├── 13-advanced-vis.assets │ ├── image-20191230215115722.png │ ├── image-20191230215554306.png │ ├── image-20191230215943127.png │ ├── image-20191230220723864.png │ ├── image-20191230220938667.png │ ├── image-20191230221009007.png │ ├── image-20191230221207470.png │ ├── image-20191230221500314.png │ ├── image-20191230221600624.png │ ├── image-20191230221709623.png │ ├── image-20191230221756287.png │ ├── image-20191230222028538.png │ ├── image-20191230222135759.png │ ├── image-20191230222321813.png │ ├── image-20191230222426218.png │ ├── image-20191230222708685.png │ ├── image-20191230223148915.png │ ├── image-20191230223250156.png │ ├── image-20191230223419554.png │ ├── image-20191230223457527.png │ ├── image-20191230223557348.png │ ├── image-20191230223710925.png │ ├── image-20191230223842550.png │ ├── image-20191230224044284.png │ ├── image-20191230224254356.png │ ├── image-20191230224358512.png │ ├── image-20191230224528932.png │ ├── image-20191230225221554.png │ ├── image-20191230225458923.png │ ├── image-20191230225647464.png │ ├── image-20191230230129141.png │ ├── image-20191230230214815.png │ ├── image-20191230230300868.png │ ├── image-20191231001708117.png │ ├── sns-add-cyl.png │ └── sns-col3-7.png ├── 13-advanced-vis.ipynb ├── 13-advanced-vis.md ├── 14-stats.assets │ ├── 1000.jpg │ ├── image-20191230232350998.png │ ├── image-20191230232550894.png │ ├── image-20191230233657424.png │ ├── image-20191230234020193.png │ ├── image-20191230234149623.png │ ├── image-20191230234242528.png │ ├── image-20191230234822443.png │ ├── image-20191231003035336.png │ └── image-20191231003204811.png ├── 14-stats.ipynb ├── 14-stats.md ├── 15-append.md ├── 16-end.md ├── QA.md ├── README.md ├── assets │ ├── 1565877938229.png │ ├── 1565878138608.png │ ├── 1565878216261.png │ ├── 1565878297820.png │ ├── 1565878448091.png │ ├── 1565878505816.png │ ├── 1565878560237.png │ ├── 1565878612454.png │ ├── 1565878849732.png │ ├── 1565878886705.png │ ├── 1565878937914.png │ ├── 1565878990096.png │ ├── 1565881098150.png │ ├── 1565881258155.png │ ├── 1565883426201.png │ ├── 1565965546720.png │ ├── 1565965576073.png │ ├── 1565968443953.png │ ├── 1566008307111.png │ ├── 1566009197372.png │ ├── 1566009715829.png │ ├── 1566009847601.png │ ├── 1566010077143.png │ ├── 1566010369211.png │ ├── 1566010491532.png │ ├── 1566010624845.png │ ├── 1566010719188.png │ ├── 1566010869416.png │ ├── 1566011014665.png │ ├── 1566011155999.png │ ├── 1566011228901.png │ ├── 1566011365121.png │ ├── 1566011464100.png │ ├── 1566011545524.png │ ├── 1566011646740.png │ ├── 1566011764310.png │ ├── 1566011842818.png │ ├── 1566011901725.png │ ├── 1566012009692.png │ ├── 1566012156747.png │ ├── 1566012247119.png │ ├── 1566012427766.png │ ├── 1566012512679.png │ ├── 1566012584741.png │ ├── 1566012743480.png │ ├── 1566012814718.png │ ├── 1566013182248.png │ ├── 1566013434471.png │ ├── 1566013535017.png │ ├── 1566013707092.png │ ├── 1566029014148.png │ ├── 1566029142554.png │ ├── 1566029266277.png │ ├── 1566029521952.png │ ├── 1566029603380.png │ ├── 1566030049989.png │ ├── 1566030181185.png │ ├── 1566030359191.png │ ├── 1566030513027.png │ ├── 1566030610383.png │ ├── 1566030719209.png │ ├── 1566030891387.png │ ├── 1566031061659.png │ ├── 1566031144809.png │ ├── 1566031232055.png │ ├── 1566031500991.png │ └── Gravitational_Waves_Original.png ├── author-and-recommendation │ ├── ShixiangWang.png │ ├── todo.docx │ ├── todo.md │ ├── 交互的Python - 思维导图.pdf │ └── 交互的Python - 思维导图.png ├── author.md ├── code │ ├── 01-introduction.txt │ ├── 02-base.txt │ ├── 03-data-structure.txt │ ├── 04-control-flow.txt │ ├── 05-function-and-module.txt │ ├── 06-numpy.txt │ ├── 07-matplotlib.txt │ ├── 08-pandas-intro.txt │ ├── 09-markdown.txt │ ├── 10-data-import.txt │ ├── 11-toolbox.txt │ ├── 12-advanced-pandas.txt │ ├── 13-advanced-vis.txt │ ├── 14-stats.txt │ ├── 15-append.txt │ └── README.txt ├── code_py │ ├── 02-base.py │ ├── 03-data-structure.py │ ├── 04-control-flow.py │ ├── 05-function-and-module.py │ ├── 06-numpy.py │ ├── 07-matplotlib.py │ ├── 08-pandas-intro.py │ ├── 09-markdown.py │ ├── 10-data-import.py │ ├── 11-toolbox.py │ ├── 12-advanced-pandas.py │ ├── 13-advanced-vis.py │ ├── 14-stats.py │ └── 15-append.py ├── collect_figs.py ├── example │ ├── H1_Strain.wav │ ├── L1_Strain.wav │ ├── first.pdf │ ├── first.png │ ├── gravity.ipynb │ └── wf_template.txt ├── fig_header.txt ├── figures │ ├── chapter01 │ │ ├── 图1-1 Jupyter官方提供的Python在线Notebook页面.png │ │ ├── 图1-10 选择合适的安装位置.png │ │ ├── 图1-11 安装进度.png │ │ ├── 图1-12 安装进度条完成.png │ │ ├── 图1-13 跳过安装 Visual Studio Code.png │ │ ├── 图1-14 本地浏览器 Jupyter Notebook 主页.png │ │ ├── 图1-15 nteract 界面.png │ │ ├── 图1-2 微软Jupyter数据科学学习平台.png │ │ ├── 图1-3 nteract官网页面.png │ │ ├── 图1-4 nteract官网页面.png │ │ ├── 图1-5 nteract官网页面.png │ │ ├── 图1-6 点击 Next .png │ │ ├── 图1-7 点击 I Agree .png │ │ ├── 图1-8 选择合适的安装类型.png │ │ └── 图1-9 选择合适的安装位置.png │ ├── chapter02 │ │ ├── 图2-1 入门示例:向屏幕输出文字.png │ │ ├── 图2-2 错误的示例.png │ │ ├── 图2-3 单元格.png │ │ ├── 图2-4 保存为 Jupyter 笔记本.jpg │ │ ├── 图2-5 Python中的四则运算.png │ │ ├── 图2-6 整除与求余.png │ │ └── 图2-7 作者的BMI指数.png │ ├── chapter05 │ │ └── 图5-1 递归可视化:捧着画框的蒙娜丽莎 (图片来自网络).png │ ├── chapter07 │ │ ├── 图7-1 使用脚本绘制图形结果.png │ │ ├── 图7-10 线图线条类型的使用.png │ │ ├── 图7-11 线图线条类型与颜色组合.png │ │ ├── 图7-12 图例的使用.png │ │ ├── 图7-13 线图自定义.png │ │ ├── 图7-14 线图用于趋势对比.png │ │ ├── 图7-15 添加坐标轴标签与标题.png │ │ ├── 图7-16 可视化特定区域.png │ │ ├── 图7-17 坐标轴反转.png │ │ ├── 图7-18 可视化特定区域(二).png │ │ ├── 图7-19 去掉轴.png │ │ ├── 图7-2 使用 Notebook 绘制图形结果.png │ │ ├── 图7-20 使 x 轴 y 轴坐标一致.png │ │ ├── 图7-21 与屏幕一致的纵横比.png │ │ ├── 图7-22 默认选项.png │ │ ├── 图7-23 使用 plot() 函数绘制点图.png │ │ ├── 图7-24 使用 scatter() 函数绘制点图.png │ │ ├── 图7-25 点与符号.png │ │ ├── 图7-26 未设置透明度之前.png │ │ ├── 图7-27 设置透明度之后.png │ │ ├── 图7-28 设置点的大小和颜色.png │ │ ├── 图7-29 加上颜色条.png │ │ ├── 图7-3 使用 MATLAB 样式绘图.png │ │ ├── 图7-30 垂直条形图示例.png │ │ ├── 图7-31 水平条形图示例.png │ │ ├── 图7-32 分组条形图示例.png │ │ ├── 图7-33 堆叠条形图示例.png │ │ ├── 图7-34 直方图.png │ │ ├── 图7-35 更改直方图的几个常用选项.png │ │ ├── 图7-36 使用直方图比较 3 个数据分布.png │ │ ├── 图7-37 二维直方图.png │ │ ├── 图7-38 饼图.png │ │ ├── 图7-39 职工学历分布.png │ │ ├── 图7-4 简单线图,使用 range() 生成 x 轴数据.png │ │ ├── 图7-40 箱线图简单示例.png │ │ ├── 图7-41 使用箱线图进行比较.png │ │ ├── 图7-42 网格子图.png │ │ ├── 图7-43 调整子图间距.png │ │ ├── 图7-44 手动绘制子图.png │ │ ├── 图7-45 同享一个 x 轴.png │ │ ├── 图7-46 设置经典风格.png │ │ ├── 图7-47 使用 seaborn 库 white 风格.png │ │ ├── 图7-48 使用 ggplot 风格.png │ │ ├── 图7-49 使用 set() 方法设置图形.png │ │ ├── 图7-5 简单线图,使用 np.arange() 生成 x 轴数据.png │ │ ├── 图7-6 首先生成空白坐标轴.png │ │ ├── 图7-7 使用面向对象接口绘图.png │ │ ├── 图7-8 一图多曲线.png │ │ └── 图7-9 线图颜色的使用.png │ ├── chapter09 │ │ ├── 图9-1 标题预览.png │ │ ├── 图9-10 参考链接预览.png │ │ ├── 图9-11 URL 预览.png │ │ ├── 图9-12 图片预览(图片来自网络).png │ │ ├── 图9-13 nteract 显示的代码块.png │ │ ├── 图9-14 nteract 显示的文本块.png │ │ ├── 图9-15 Notebook 书写简单示例.png │ │ ├── 图9-16 Notebook 示例(一).png │ │ ├── 图9-17 Notebook 示例(二).png │ │ ├── 图9-2 列表预览.png │ │ ├── 图9-3 任务列表预览.png │ │ ├── 图9-4 代码块预览.png │ │ ├── 图9-5 公式预览.png │ │ ├── 图9-6 表格预览.png │ │ ├── 图9-7 表格对齐预览.png │ │ ├── 图9-8 脚注预览.png │ │ └── 图9-9 行内链接预览.png │ ├── chapter10 │ │ └── 图10-1 HDF5 存储的时间序列数据可视化.png │ ├── chapter12 │ │ ├── 图12-1 Numpy 数组与 Pandas 数据结构对比(图片来自网络).png │ │ ├── 图12-10 分组箱线图.png │ │ ├── 图12-11 面积图.png │ │ ├── 图12-12 散点图.png │ │ ├── 图12-13 饼图.png │ │ ├── 图12-14 饼图(2).png │ │ ├── 图12-2 使用 plot 方法自动生成线图.png │ │ ├── 图12-3 条形图.png │ │ ├── 图12-4 水平条形图.png │ │ ├── 图12-5 堆叠条形图.png │ │ ├── 图12-6 直方图.png │ │ ├── 图12-7 直方图,设置条形数量.png │ │ ├── 图12-8 分组直方图.png │ │ └── 图12-9 箱线图.png │ ├── chapter13 │ │ ├── 图13-1 mtcars 数据集变量成对相关图.png │ │ ├── 图13-10 条形图.png │ │ ├── 图13-11 分组条形图.png │ │ ├── 图13-12 计数图.png │ │ ├── 图13-13 点图.png │ │ ├── 图13-14 箱线图.png │ │ ├── 图13-15 小提琴图.png │ │ ├── 图13-16 双变量分布图展示核密度.png │ │ ├── 图13-17 双变量分布图展示分布和线性回归.png │ │ ├── 图13-18 plotnine 示例.png │ │ ├── 图13-19 ggplot 点图.png │ │ ├── 图13-2 mtcars 数据集相关图选择性展示.png │ │ ├── 图13-20 ggplot 画布.png │ │ ├── 图13-21 ggplot 点图实现.png │ │ ├── 图13-22 ggplot 线图.png │ │ ├── 图13-23 ggplot 线性回归.png │ │ ├── 图13-24 ggplot 点图加线性回归.png │ │ ├── 图13-25 ggplot 修改图形参数.png │ │ ├── 图13-26 ggplot 修改引导元素.png │ │ ├── 图13-27 ggplot 分面图.png │ │ ├── 图13-28 ggplot 错误分面图.png │ │ ├── 图13-29 ggplot 组合实例.png │ │ ├── 图13-3 wt 与 mpg 成对相关图.png │ │ ├── 图13-30 Bokeh 散点图.png │ │ ├── 图13-31 Bokeh 线图.png │ │ ├── 图13-32 Bokeh 组合图.png │ │ ├── 图13-33 Bokeh 水平排列.png │ │ ├── 图13-34 Bokeh 垂直排列.png │ │ ├── 图13-35 Bokeh 网格排列.png │ │ ├── 图13-4 按 cyl 分组成对相关图.png │ │ ├── 图13-5 风格调整.png │ │ ├── 图13-6 子集图.png │ │ ├── 图13-7 子集图(2).png │ │ ├── 图13-8 回归图.png │ │ └── 图13-9 核密度图.png │ └── chapter14 │ │ ├── 图14-1 汽车数据集变量 wt 分布图.png │ │ ├── 图14-10 两样本数据分布直方图.png │ │ ├── 图14-2 汽车数据集变量 cyl 分布图.png │ │ ├── 图14-3 标准正态分布.png │ │ ├── 图14-4 二项分布.png │ │ ├── 图14-5 二项分布(2).png │ │ ├── 图14-6 伯努利分布.png │ │ ├── 图14-7 指数分布.png │ │ ├── 图14-8 泊松分布.png │ │ └── 图14-9 标准正态分布经验法则图示(图片来自网络).jpg ├── files │ └── chapter10 │ │ ├── data.db │ │ ├── data.hdf5 │ │ ├── data.html │ │ ├── data.json │ │ ├── data.pkl │ │ ├── data.xlsx │ │ ├── data1.yml │ │ ├── data2.yml │ │ ├── lung.csv │ │ ├── mtcars.csv │ │ ├── records.csv │ │ ├── records.tsv │ │ ├── records.txt │ │ ├── test1.csv │ │ └── test2.csv ├── get_code.sh ├── get_code_py.sh ├── get_fig_header.sh ├── images │ ├── chapter1 │ │ ├── Online_jupyter.png │ │ ├── Online_jupyter_Miscrosoft.png │ │ ├── download_anaconda_0.png │ │ ├── download_anaconda_win.png │ │ ├── download_nteract_0.png │ │ ├── download_nteract_1.png │ │ ├── install_anaconda_win_1.png │ │ ├── install_anaconda_win_2.png │ │ ├── install_anaconda_win_3.png │ │ ├── install_anaconda_win_4.png │ │ ├── install_anaconda_win_5.png │ │ ├── install_anaconda_win_6.png │ │ ├── install_anaconda_win_7.png │ │ ├── install_anaconda_win_8.png │ │ ├── install_notes.png │ │ ├── install_nteract_0.png │ │ ├── install_nteract_1.png │ │ ├── nb_home.png │ │ ├── nteract_1.png │ │ ├── nteract_web.png │ │ ├── use_anaconda_win_1.png │ │ ├── use_anaconda_win_2.png │ │ ├── use_anaconda_win_3.png │ │ ├── use_anaconda_win_4.png │ │ ├── use_anaconda_win_5.png │ │ ├── use_anaconda_win_6.png │ │ ├── use_anaconda_win_7.png │ │ └── use_nteract_0.png │ ├── chapter10 │ │ └── hdf5_time_series.png │ ├── chapter12 │ │ └── numpy_pandas_comparison.png │ ├── chapter2 │ │ ├── nteract_My_bmi.png │ │ ├── nteract_cell.png │ │ ├── nteract_hello_world.png │ │ ├── nteract_hello_world_wrong.png │ │ ├── nteract_save.jpg │ │ ├── nteract_sg_calc.png │ │ └── nteract_sg_calc2.png │ ├── chapter5 │ │ └── mnlisha.png │ └── chapter7 │ │ └── Figure_1.png ├── interactive_python.docx ├── merge_book.sh ├── rm_space.sh ├── swap_line.R ├── to-readers.md ├── 人邮社出版流程等参考文档 │ ├── 01出版流程.docx │ ├── 02原创图书写作注意事项及说明.docx │ ├── 04参考目录.doc │ ├── 05参考样章.doc │ ├── 06参考程序样式.docx │ ├── 07参考内容提要.docx │ └── 08参考前言.doc └── 大纲.md └── mkdocs.yml /.github/workflows/jekyll-gh-pages.yml: -------------------------------------------------------------------------------- 1 | name: Publish docs via GitHub Pages 2 | on: 3 | push: 4 | branches: 5 | - main 6 | - master 7 | 8 | jobs: 9 | build: 10 | name: Deploy docs 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout main 14 | uses: actions/checkout@v2 15 | 16 | - name: Deploy docs 17 | uses: mhausenblas/mkdocs-deploy-gh-pages@master 18 | env: 19 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 20 | CONFIG_FILE: mkdocs.yml 21 | EXTRA_PACKAGES: build-base 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .ipynb_checkpoints/ 2 | .DS_Store -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "terminal.integrated.fontSize": 11, 3 | "python.pythonPath": "D:\\Tool\\miniconda\\python.exe" 4 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 交互的 Python(Interactive Python) 2 | 3 | [![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fshixiangwang%2Fpybook&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=%E9%98%85%E8%AF%BB%E9%87%8F&edge_flat=false)](https://hits.seeyoufarm.com) 4 | 5 | > 一本 Python 数据分析入门图书,2020 年 7 月出版,[京东](https://item.jd.com/12898428.html)和[当当](http://product.dangdang.com/28972974.html)等平台有售,感兴趣的读者可以根据情况购买。本仓库存储了出版校对前的版本(可能存在未校对的问题和错误),读者可以通过 Markdown/docx 文件或者 [GitHub 提供的网页](https://shixiangwang.github.io/pybook/)阅读。**请勿恶意分享和传播,违权必究!** 6 | 7 | ![](https://img30.360buyimg.com/vc/jfs/t1/125099/2/5011/555980/5ee73ba4E8cebccc4/2a581884573651e8.jpg) -------------------------------------------------------------------------------- /docs/.Rhistory: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/.Rhistory -------------------------------------------------------------------------------- /docs/0-前言.md: -------------------------------------------------------------------------------- 1 | # 前言 2 | 3 | ## 编写背景 4 | 5 | 如今,来自手机、互联网、物联网、科学实验、新闻等各处的信息每天创造着数以万亿字节的数据。在这万物互联的时代,信息技术将人类对数据的创造力一波又一波地推向新的巅峰。我们对计算机、手机中各种 App 的每一次点击与字符输入,对歌曲、文章的每一次点赞、喜欢、评论等操作都将零散单薄的数据汇入了信息的海洋,在大数据、人工智能技术的运用下激荡出新的浪花。而在这片汪洋大海下,数据科学成为沉淀下来的理论与科学基础。 6 | 7 | 作为当前最流行的编程语言之一,Python在过去几十年已被广泛应用于系统管理任务的处理和网络编程等领域,接触过网络 Web 编程读者想必很熟悉基于Python语言的 Django 框架。得益于机器学习、深度学习的兴起,近些年 Python 在科学计算领域绽放出新的光芒。在 IEEE 发布的 2017 年编程语言排行榜中,Python 高居首位。不同于 MATLAB 等商业软件,Python 是完全免费和开源的;不同于 R 等主要用于统计分析与建模的开源软件比较难以将成果扩展为完整的应用程序,Python 有着非常丰富的扩展库(模块),可以轻松完成各种高级任务,将项目的所有需求一起实现。 8 | 9 | 然而,国内少有聚焦于数据分析领域的 Python 图书,来自国外的译作大多起点较高,并不十分适合零基础的读者学习和使用。因此,我写作了本书——《交互的 Python:数据分析入门》。“交互”一词可能更容易让人们联想到“人机交互”,百度百科中的解释为“一门研究系统与用户之间交互关系的学问”。与普通的 Python 编程或其他编程(“编辑-编译-运行”的工作模式)有所不同,利用 Python 处理数据时,用户能够感受到一种极强的交互性,在数据分析时我们常常缺乏明确的目的和解决方案,因而不断地尝试各种分析——键入代码、查看结果、修正、重新运行查看结果,这一不断循环的过程往往是基于探索的,我们可以将其简化为“运行-探索”的工作模式。除此之外,**动态文档**是数据分析的一个新的流行趋势,普通的编程是进行应用程序的开发,数据分析则是进行数据的探索以及生成相关报表供用户阅读和研究。所以在本书的结构安排上,我添加了关于 Markdown 标记语言的内容。**数据分析过程,就应当像写文章一样**。 10 | 11 | ## 谁当阅读此书 12 | 13 | 本书是 Python数据分析的入门教程,**主要为新手设计**,也同样适用于想要了解或者打算进入数据分析领域的程序员。注意,**本书绝不是一本技术手册**,其中没有讲解关于 Python 的所有领域的知识,比如网络编程、游戏编程、界面设计等;也不会事无巨细地讲解 Python 的所有基础知识,而是侧重于解读数据分析和科学计算知识。 14 | 15 | ## 本书特色 16 | 17 | 1. 实例丰富,简单易懂。从简单的数据出发,让读者聚焦于思考、理解和掌握分析逻辑,简单易学,事半功倍。 18 | 2. 循序渐进,深入浅出。本书的章节安排由易到难,由浅及深,主要采用 IPython Shell 展示代码,代码简洁优美,输入输出清晰易懂。 19 | 3. 内容充实,全面覆盖。涵盖 Python 基础知识、数据导入、数据分析和可视化等方面的基础知识。 20 | 4. 随学随用,举一反三。从简单的需求出发,阐述逻辑,实例方案可以作为模板初步应用到实际工作场景。本书将 Markdown 作为编程基础的一部分加以介绍,以使读者学会记录和分享知识。 21 | 22 | ## 内容简介 23 | 24 | 本书共分为 15 章。 25 | 26 | - 第 1 章介绍 Python 软件的安装与配置。 27 | - 第 2 章介绍 Python 的基本编程方式和数据类型。 28 | - 第 3 章介绍 Python 核心数据结构的使用,包括列表、元组、字典和集合。 29 | - 第 4 章介绍 Python 的条件判断与循环控制,这是任何语言都具备的核心语法,并简单介绍如何操作文件。 30 | - 第 5 章介绍 Python 函数的创建和使用、模块的下载和使用。 31 | - 第 6 章介绍 NumPy 库及其核心数据结构 ndarrary 的操作方法。 32 | - 第 7 章介绍 Matplotlib 库的应用场景和基本图形的绘制方法。 33 | - 第 8 章介绍 Pandas 库及其核心数据结构 Series 和 DataFrame 的基本操作方法,并讲解如何进行简单的统计分析。 34 | - 第 9 章介绍 Markdown 的语法和使用, Jupyter Notebook 的使用、记录和编程知识。 35 | - 第 10 章介绍如何将数据导入 Python 中,包括常见的 CSV、Excel 文件,网络数据常用的 JSON 文件和数据库。 36 | - 第 11 章介绍一些技巧性和高级编程知识,包括异常捕获、正则表达式和函数式编程等内容,以便读者更好地理解 Python,编写安全高效的代码。 37 | - 第 12 章深入介绍 Pandas 的数据结构和操作,讲解如何进行函数计算、数据清洗和简单的可视化。 38 | - 第 13 章简单介绍 3 个高级的可视化库 Seaborn、Plotnine 和 Bokeh ,并讲解如何使用它们绘制常见的图形。 39 | - 第 14 章简单介绍统计分析的基础理论知识,包括数据的描述性统计、分布和假设检验。 40 | - 第 15 章补充介绍一些内容,包括 IPython 的魔术命令和面向对象编程知识。 41 | 42 | ## 建议和反馈 43 | 44 | 写书是一项繁琐的工作,尽管我已力求本书内容简明、生动、准确,但限于个人水平,难免有错漏之处,恳请各位读者批评指正。读者若有任何关于本书的反馈意见,请提交至异步社区的本书页面中,这将有利于我改进本书,使更多读者受益。 45 | 46 | ## 致谢 47 | 48 | 本书的内容基于 Python 和诸多第三方库,在此感谢 Python 积极活跃的数据科学生态,系统以及 NumPy、Pandas、Matplotlib、Plotnine 和 Seaborn 等第三方库的作者们。 49 | 50 | 感谢出版社的张爽编辑,她对于本书内容的把握和细节的重视极大地提高了本书的质量。 51 | 52 | 感谢简书的毛晓秋女士和其他工作人员,如果不是他们的努力和鼓励,本书可能很难与众位读者见面。 53 | 54 | 最后,感谢我的女朋友,如果不是她时刻的敦促,我也许无法创作一本书投入持续的热情和精力;感谢我的家人,他们在远方的陪伴,是我能够写作的最坚实的动力。 55 | 56 | 王诗翔 57 | 58 | 2020年1月于上海 59 | 60 | -------------------------------------------------------------------------------- /docs/00-内容提要.md: -------------------------------------------------------------------------------- 1 | # 内容提要 2 | 3 | Python 具有强大的应用能力,以及便捷高效的数据分析和可视化拓展包系统。本书重点讲解 Python 数据分析的基础知识,使读者通过 Python 理解数据分析的逻辑,并掌握基本的 Python 编程知识和分析实现方法。本书系统全面、循序渐进地介绍了 Python 编程基础、数据导入、数据分析和可视化,例如条件判断与循环控制、从 Excel 中导入数据、使用 Pandas 库进行数据的转换和计算,以及使用 Plotnine 库绘制 ggplot 风格的图形等。此外,本书还涉及 Markdown 、基本的统计理论和 IPython 魔术命令等技巧性内容。 4 | 5 | 本书可以作为 Python 编程和数据分析入门级读者的学习用书,也适用于数据分析相关从业人员阅读,还可以作为高等院校计算机、统计及相关专业的师生用书和培训学校的教材。 6 | 7 | 8 | -------------------------------------------------------------------------------- /docs/01-introduction.md: -------------------------------------------------------------------------------- 1 | # 第 1 章 Python 介绍及学习前的准备 2 | 3 | **本章内容提要**: 4 | 5 | - Python 是什么 6 | - 为什么要使用 Python 进行数据分析 7 | - 科学计算核心库简介 8 | - 软件安装与配置 9 | 10 | 本书在正式向读者介绍 Python 的基本语法与操作之前,通过本章向读者简要介绍 Python 的定义与利用 Python 进行数据处理的优势,详述学习 Python 之前相关软件的安装与配置。 11 | 12 | ## 1.1 Python 是什么 13 | 14 | 在 IEEE 发布的 2017 年编程语言排行榜中,Python 高居首位。对于这样一门流行的编程语言, 15 | 很多的 Python 入门图书都给它进行定义,但本书作者认为,较为清晰明了的定义来自维基百科: 16 | 17 | > Python 是一种广泛使用的高级编程语言,属于通用型编程语言,由吉多·范罗苏姆创造,第一版发布于 1991 年。Python 可以被视之为一种改良(加入一些其他编程语言的优点,如面向对象) 的 LISP。作为一种解释型语言,Python 的设计哲学强调代码的可读性和简洁的语法(尤其是使用空格缩进划分代码块,而非使用大括号或者关键词)。相比于 C++ 或 Java,Python 让开发者能够用更少的代码表达想法。无论是小型还是大型程序,Python 都试图让程序的结构清晰明了。 18 | 19 | 这段文字囊括了读者需要了解的关于 Python 的基本信息。 20 | 21 | 1. Python 目前被广泛使用。 22 | 2. Python 属于高级编程语言,这区别于 C 语言这样的中级语言或是底层的硬件编程、汇编等语言。 23 | 3. Python 由吉多·范罗苏姆创造,于1991年发布。 24 | 4. Python 支持面向对象编程(Object-Oriented Programming,OOP)。 25 | 5. Python 属于解释型语言,解释型语言以文本的方式存储程序代码,不需要在运行前进行编译(为大众所熟知的 C 语言就不是解释型语言,在运行前必须编译为机器识别的语言)。 26 | 6. 强调代码的可读性和简洁的语法是 Python 的设计哲学,这一点尤其需要注意和理解,因为这是 Python 在形式上最有别于其他编程语言之处。Python 使用空格的缩进来划分不同的代码块,其他一些常见语言一般使用大括号或者关键字,正是这个特点,让 Python 代码无论大小长短都看起来非常简单清晰,易于使用(读者将会在本书学习的过程中深入理解这一特点)。 27 | 28 | 了解一门语言的历史和特点有助于提升读者对其语法的理解和快速应用能力。读者有闲暇不妨通过搜索引擎查查 Python 设计的初衷和一些 Python 开发的著名项目。 29 | 30 | ## 1.2 为什么要使用 Python 进行数据分析 31 | 32 | 在成为数据分析和人工智能等领域的头号选手之前,Python 早就因其大量的 Web 框架、丰富的标准库以及众多的扩展库等特点成为网络建站、系统管理、信息安全等领域的热门方案。例如,有名的豆瓣网站就是基于 Python 开发,Linux 所有的发行版都默认安装了 Python。 33 | 34 | 近年来,Python 的科学计算库(如结构化数据操作库 Pandas、机器学习库 scikit-learn)不断进行改良,使得利用 Python 来进行数据分析成了优选方案。Python 还有一个胶水语言的外号,这来源于它能够非常轻松地集成 C、C++ 等底层代码,进行计算优化。与 SAS 和 R 等分析建模领域特定编程语言相比,Python 可以同时用于项目原型的构建和生产(前者则主要用于项目原型的构建),从而避免了使用多个语言的麻烦。加上Python 本身多年来不断提升的强大编程能力,用户只需要使用 Python 就可以完成以数据为中心的建模、分析与应用。 35 | 36 | 可以说,Python 在数据分析领域的迅猛发展与其本身非常成熟且广泛应用是分不开的,Python 开源、简明易用的特点也让开发者和使用者自觉倾注精力共同维护社区环境,构建了整个 Python 计算分析领域的良好生态系统。 37 | 38 | ## 1.3 科学计算核心库简介 39 | 40 | Python 拥有着众多的软件包/库,本书难以全部涉及,这里仅介绍几个构成 Python 科学计算生态系统的核心成员。 41 | 42 | * NumPy:NumPy 是 Numerical Python 的简称。NumPy 是 Python 科学计算最基础的库,基本上涉及数据分析的软件包都基于它构建。 43 | * Pandas:Pandas 的名字来源于 Python 数据分析(Python data analysis)和面板数据(Panel data)的结合。该库提供了多个数据存储对象,其中的 DataFrame 对象可以表征数据分析常见的二维表格。除此之外,它还提供了非常多便捷处理结构化数据的函数。 44 | * Matplotlib:Matplotlib 起源于矩阵实验室 MATLAB 中的绘图函数,是 Python 中非常流行的绘图库,可以轻松进行二维数据甚至多维数据可视化。 45 | * SciPy:SciPy 库提供了一组专门用于科学计算中各种标准问题包,如数值积分、微分、信号处理、统计分析,它与 NumPy 的结合可以处理诸多科学计算问题。 46 | * Jupyter:Jupyter 是一个交互和探索式计算的高效环境。其中两个组件较为常用,一是 IPython,用于编写、测试和调试 Python 代码;二是 Jupyter Notebook,它是一个多语言交互式的 Web 笔记本,现在支持运行 Python、R 等多种语言,Jupyter Notebook 中代码与 Markdown 的结合可以创建良好、可重复的动态文档。这也是读者进行 Python 数据分析的学习环境。 47 | 48 | ## 1.4 搭建环境 49 | 50 | Python 存在 Python2(现在一般指 Python2.7)和 Python3(现在一般指 Python3.5 及以上)两个不同的大版本。Python 官方宣布于 2020 年停止 Python2 的更新和维护,全面进入 Python3 时代。考虑到学习和应用的普适性,本书的介绍以 Python3 版本为基础。 51 | 52 | 目前流行的 Python 集成开发环境(IDE)有很多,如 PyCharm、Sublime Text、Eclipse+PyDev 和 Anaconda 中的 Spyder。不同的软件、系统的安装和配置方式各不相同,本书使用 Anaconda 平台的 Jupyter Notebook 对 Python 进行介绍。Anaconda 是非常强大的跨系统开源计算平台,支持个人 PC 使用的 Windows、Linux 和 macOS,提供的近 1000 个开源软件包基本上可以满足个人或团队进行数据处理的需求。 53 | 54 | 为了满足不同读者的需求,本书介绍两种 Python 线上平台、以及本地机器环境下相关软件的安装和配置,读者可任意选择使用。 55 | 56 | ### 1.4.1 线上平台 57 | 58 | 网络上现在有很多在线的 Python 解释器,读者可以在计算机有网络服务的情况下通过浏览器运行代码。因为软件包的导入和计算都在服务器端,所以读者不需要较高配置的计算机就能进行 Python 的学习和数据分析。 59 | 60 | 本书推荐两个免费的 Jupyter Notebook 网站,读者可结合自己计算机的配置和网络情况进行选择。 61 | 62 | 1. Jupyter 官方提供的 Try Jupyter 网站 (),该网站包含学习在 Jupyter 中使用 Python 和文本书写的例子和练习,读者可以在 Try Python with Jupyter 的主页(在 Try Jupyter 网站选择使用 Python)运行、调试代码,并下载 Jupyter 笔记本到本地存储。 63 | 64 | ![图1-1 Jupyter官方提供的Python在线Notebook页面](images/chapter1/Online_jupyter.png) 65 | 66 | 2. 微软公司提供的 Jupyter 数据探索学习平台 Azure(),如图1-2所示,支持在线运行多种编程语言进行数学科学探索,其中比较常用的是 Python 和 R。读者可以通过微软账户创建仓库,新建 Jupyter Notebook 并书写代码和探索数据,完成后可以保存、与他人分享(使用过 GitHub 等开源仓库的读者会发现这个平台的操作和它们极为相似)。 67 | 68 | ![图1-2 微软Jupyter数据科学学习平台](images/chapter1/Online_jupyter_Miscrosoft.png) 69 | 70 | 本书作者推荐读者使用 Azure 平台,因为其在创建、使用、保存与分享方面占有优势,不过读者首先需要创建一个微软账号。 71 | 72 | 随着时间的推移,我们相信会有越来越多的线上 Jupyter Notebook 平台,感兴趣的读者不妨搜索汇总并选择最适合自己学习和使用的平台。 73 | 74 | ### 1.4.2 本地机器环境下相关软件的安装 75 | 76 | 读者如果想要在本地部署学习环境,那么可以选择安装两款软件。第一款软件是上文已经提到的 Anaconda,其为必需软件;第二款软件为 nteract(),见图1-3,为可选软件。与 Anaconda 默认提供的 Jupyter Notebook 不同,nteract 像我们常用的文字编辑器一样,界面非常简洁酷爽,可以非常方便地编辑 Jupyter Notebook 文件(文件扩展名为 .ipynb )。本书作者推荐读者使用 nteract,本书后续的代码和文档展示都会使用到它,虽然 nteract 目前只有 alpha 版本(测试版),功能还在不断完善中,但是这不会影响读者使用它学习 Python。其实,由于 Jupyter Notebook 与 nteract 运行 Python 都是基于 IPython 内核 ipykernel,除了界面、显示效果和一些细微之处,两者在使用上并没有太多的不同,因此读者不用担心是选择使用默认 Jupyter Notebook 还是 nteract 进行 Python 学习的问题。 77 | 78 | ![图1-3 nteract官网页面](images/chapter1/nteract_web.png) 79 | 80 | #### Anaconda 的下载与安装 81 | 82 | 读者需要到Anaconda官网下载地址()下载对应操作系统的 Python3 版本 Anaconda。 83 | 84 | 在搜索引擎键入关键字 Anaconda 也可以轻松地找到 Anaconda 官网地址,如图1-4所示。 85 | 86 | ![图1-4 nteract官网页面](images/chapter1/download_anaconda_0.png) 87 | 88 | Anaconda 下载页面会根据读者使用的操作系统(Windows、Linux、macOS)自动推荐相应的安装包,如图1-5所示,读者根据自己的操作系统位数(目前市面上的计算机以 64 位为主)点击左侧 Download 下方的下载链接进行下载。 89 | 90 | ![图1-5 nteract官网页面](images/chapter1/download_anaconda_win.png) 91 | 92 | 如果读者阅读本书时,Anaconda 的 Python 版本与图1-5所示的 Python3.7 有所不同,读者可以选择更新的版本或者在网络上寻找 Python3.7 版本 Anaconda 进行下载。由于 Python 的向下兼容性,使用更新的版本本书所有示例代码不出意外也都能成功运行。 93 | 94 | ##### Anaconda 在 Windows 与 macOS 系统上的安装 95 | 96 | Windows 与 macOS 系统中 Anaconda 安装都是图形化的,与普通办公软件的安装类似,非常简单。 97 | 98 | 下面以 Windows 系统下的安装为例进行详细说明。 99 | 100 | 首先双击下载的 Anaconda 安装器,点击 Next ,如图1-6所示。 101 | 102 | ![图1-6 点击 Next ](images/chapter1/install_anaconda_win_1.png) 103 | 104 | 程序会弹出许可协议界面,点击 I Agree ,如图1-7所示。 105 | 106 | ![图1-7 点击 I Agree ](images/chapter1/install_anaconda_win_2.png) 107 | 108 | 接下来程序要求选择安装类型:读者是为计算机的每一位用户(第二项)还是仅仅当前用户(第一项)安装 Anaconda。如果读者不确定,选择默认选项,点击 Next 即可,如图1-8所示。 109 | 110 | ![图1-8 选择合适的安装类型](images/chapter1/install_anaconda_win_3.png) 111 | 112 | 接下来读者需要为 Anaconda 选择合适的安装位置。本书作者推荐读者将 Anaconda 安装在用户目录的 Anaconda3 目录(如果不存在可以新建)下,如图1-9。如果读者选择其他目录,请尽量避免安装路径含中文名称。 113 | 114 | ![图1-9 选择合适的安装位置](images/chapter1/install_anaconda_win_4.png) 115 | 116 | 接下来一步是设定高级安装选项:环境变量。虽然 Anaconda 默认不推荐将 Anaconda 添加到环境变量,但本书作者推荐读者勾选该选项,如图1-10 所示。勾选该选项的好处是读者可以通过终端(Windows 中的 cmd)访问所有的 Anaconda 组件,包括 Python、Spyder、Jupyter Notebook 等。 117 | 118 | ![图1-10 选择合适的安装位置](images/chapter1/install_anaconda_win_5.png) 119 | 120 | 点击 Install 进行安装。由于安装的东西很多,整个安装过程耗时较长,一般需要半小时左右,请读者耐心等待。 121 | 122 | ![图1-11 安装进度](images/chapter1/install_anaconda_win_6.png) 123 | 124 | 安装进度条完成后点击 Next 。 125 | 126 | ![图1-12 安装进度条完成](images/chapter1/install_anaconda_win_7.png) 127 | 128 | Anaconda 推荐安装 VS Code 代码编辑器,该软件可装可不装,读者自行选择。如果不安装,点击 Skip 跳过即可,如图1-13所示。 129 | 130 | ![图1-13 跳过安装 Visual Studio Code](images/chapter1/install_anaconda_win_8.png) 131 | 132 | 最后点击 Finish 完成安装过程。 133 | 134 | ##### Anaconda 的 Linux 版本的安装 135 | 136 | 在 Linux 系统上安装 Anaconda 是使用命令行方式进行的(macOS 也可以),下载完 Anaconda 的 Linux 版本后,打开文件所在目录并在该目录下打开终端(也可以从其他目录使用 cd 命令切换)。 137 | 138 | 然后,输入命令: 139 | 140 | ```shell 141 | # 除了使用浏览器,也可以通过终端运行以下命令下载 Anaconda 142 | # wget -c https://repo.anaconda.com/archive/Anaconda3-2018.12-Linux-x86_64.sh 143 | 144 | # 添加执行权限 145 | chmod u+x Anaconda3-2018.12-Linux-x86_64.sh 146 | # 执行安装 147 | ./Anaconda3-2018.12-Linux-x86_64.sh 148 | 149 | # 也可以直接使用Bash进行安装 150 | bash Anaconda3-2018.12-Linux-x86_64.sh 151 | ``` 152 | 153 | 接着按照提示按回车键或 Yes 。注意最后安装程序提示是否将 Anaconda 添加到环境变量时一定要键入 Yes 同意。 154 | 155 | 最后测试下 Anaconda 是否已经安装成功。新建一个终端,键入下面命令将会打开 Jupyter Notebook(在 Windows 操作系统中,使用组合键,然后输入 cmd )。 156 | 157 | ```shell 158 | jupyter notebook 159 | ``` 160 | 161 | 默认情况下,浏览器会自动打开,跳转到主页面,如图1-14。 162 | 163 | ![图1-14 本地浏览器 Jupyter Notebook 主页](images/chapter1/nb_home.png) 164 | 165 | 166 | 如果读者还想要进一步了解 Anaconda 及其安装、Jupyter Notebook 相关知识,不妨多查阅网络上的资料,目前网上相关的介绍和问题解答非常丰富。 167 | 168 | 169 | #### nteract 下载与安装 170 | 171 | 读者可以到 nteract 官网()下载不同操作系统对应的软件版本,Windows、macOS 与 Linux上 都可以直接点击安装。 172 | 173 | 安装后直接点击软件图标打开,软件主界面如图1-15所示。 174 | 175 | ![图1-15 nteract 界面](images/chapter1/use_nteract_0.png) 176 | 177 | 单击菜单栏中的 Runtime ,如果出现 Python 字样,那么说明 nteract 可以正常使用,同时左下方也会出现 python3 标记。如果没有出现上述内容,那么读者需要检查是否已经成功安装 Anaconda 并将其添加到环境变量。 178 | 179 | 到此为止,读者已经成功地搭建 Python 的学习环境,迈出了学习 Python 数据分析的第一步。从下一章开始,我们将正式进入 Python 基本语法与操作的学习。 180 | 181 | ## 1.5 章末小结 182 | 183 | 本章向读者简要介绍了 Python 的定义、使用 Python 进行数据分析的优势、进行科学计算的几个重要库(软件包)以及线上 Python 平台、本地 Python 学习环境的安装。本书推荐读者使用 Anaconda(必备)与 nteract(可选)作为读者的 Python 学习平台。 184 | 185 | Anaconda 已经在数据分析领域中广为流行,其中 Jupyter 是核心工具。Jupyter Notebook 和 nteract 都是基于 Jupyter 底层核心的图形界面,读者可以根据自己的实际情况灵活选择和使用。除此之外,Python 流行的集成开发环境(Integrated development environment,IDE)或代码编辑器很多,各有特色,倾向使用其他 IDE 或编辑器的读者不妨参考网络资料进行 Python 环境的配置。 186 | 187 | Anaconda 平台除了 Jupyter,还包含一些其他的重要软件和插件(如Spyder、Jupyter Lab)。因为对它们的介绍不是本书核心内容,所以没有在本章一一罗列,感兴趣的读者可以通过网络资料进行了解和学习。 188 | 189 | -------------------------------------------------------------------------------- /docs/09-markdown.md: -------------------------------------------------------------------------------- 1 | # 第 9 章 Markdown 基础 2 | 3 | **本章内容提要**: 4 | 5 | - 为什么学习 Markdown 6 | - Markdown 支持软件 7 | - Markdown 基础语法 8 | - Markdown 文档范例 9 | 10 | 网络促进了知识的传播与分享。各大技术博客、自建博客中,伴随着当前编程技术知识流行于网络的,还有书写知识的工具,它就是 Markdown。也许会有读者对一本 Python 书籍使用一章的篇幅讲解 Markdown 的知识感到奇怪,但毋庸置疑的是,潮流已经将它与 Python 联系在一起,让我们勇敢地拥抱它吧。 11 | 12 | ## 9.1 Markdown 简介 13 | 14 | Markdown 由 John Gruber 于 2004 年创建,它是一种轻量级标记语言。轻量级标记语言是指一类用简单语法表述文字格式的文本语言,即直接能从字面上进行阅读和理解。Markdown 的目的是提供一种容易阅读、容易书写的纯文字格式,它吸收了电子邮件中许多已有的标 记特性,并可以有效地转换为富文本语言,如 HTML。 15 | 16 | 由于 Markdown 轻量、易读、易写的特性,并且支持图片、表格、数学公式,目前许多网站都采用 Markdown 来编写帮助文档或发布消息,比较有名的有 GitHub、reddit 和 Stack Overflow。另外,Markdown 也常用与博文、书籍的撰写。甚至当前网络应用、App 专门提供 Markdown 服务,如简书、Slack。 17 | 18 | 随着时间的推移,出现了许多 Markdown 的实现。这些实现的目的是在 Markdown 基础语法之上添加一些额外的功能,如列表、脚注等。另外,在数据分析领域,一种新型的文档出现了,它可以将文本嵌入运行的代码中,称为动态文档,而文本书写的语法正是 Markdown。目前流行的动态文档主要有 2 种,一种是 Jupyter Notebook,它支持多种编程语言,包括 R、Python;另一种是 Rmarkdown,它在 Markdown 的基础上增加了 R 语言代码块的执行功能(也有对 Python、Shell 的支持,但功能较弱)。 19 | 20 | 动态文档的出现使得数据分析不再像是在写单纯的功能脚本,而是图文并茂的文章,而且增强了交互性和可重复性,已经是当下数据分析人员必备的一个技能之一。 21 | 22 | 在本章接下来的内容中,本书将对 Markdown 的基础语法进行简要介绍并结合 Python 分析实际使用进行举例。 23 | 24 | ## 9.2 Markdown 语法 25 | 26 | 为了更好地向读者展示 Markdown 语法的显示效果,这一节本书使用了一个开源且非常流行的工具 Typora。读者可以下载该软件并自己根据学习和理解测试效果,当然也可以使用 Jupyter Notebook 或 nteract,不过相对而言 Typora 更为美观。 27 | 28 | ### 9.2.1 块元素 29 | 30 | #### 段落 31 | 32 | Markdown 中,段落是通过一个及以上空行来分割的。如下所示: 33 | 34 | ``` 35 | 这是第一段话 36 | 37 | 这是第二段话 38 | ``` 39 | 40 | 如果只是使用回车键,内容还是属于一段,文字是连接起来的。 41 | 42 | 例如, 这是第一句话。这是第二句话。 可以写为如下形式: 43 | 44 | ``` 45 | 这是第一句话。 46 | 这是第二句话。 47 | ``` 48 | 49 | #### 标题 50 | 51 | Markdown 支持 6 级标题,一般前四级比较常用。指定标题的方式是在文字前面添加井号键,有几个就是几级标题。 52 | 53 | ``` 54 | # 这是一级标题 55 | 56 | ## 这是二级标题 57 | 58 | ### 这是三级标题 59 | 60 | #### 这是四级标题 61 | 62 | ##### 这是五级标题 63 | 64 | ###### 这是六级标题 65 | ``` 66 | 67 | 注意井号后面加一个空格。 68 | 69 | ![图9-1 标题预览](assets/1565877938229.png) 70 | 71 | #### 引用 72 | 73 | Markdown使用符号 > 起始一段块引用。引用也可以有多段文字,换行以单独的 > 为一行。 74 | 75 | ``` 76 | > 这里有3段引用,前面2段引用是在一起的,最后一段引用是独立的。 77 | > 78 | > 这是第2段引用。 79 | 80 | 81 | > 这是第3段引用。 82 | ``` 83 | 84 | 下面则是 Markdown 显示的效果。 85 | 86 | > 这里有3段引用,前面2段引用是在一起的,最后一段引用是独立的。 87 | > 88 | > 这是第2段引用。 89 | 90 | 91 | > 这是第3段引用。 92 | 93 | #### 列表 94 | 95 | 输入 \* 元素1 就可以创建一个无序列表,除了使用星号 \*,还可以使用 +、-。一般常用 \* 或者 -。而输入 1. 元素1 可以创建有序列表。 96 | 97 | Markdown 源代码如下: 98 | 99 | ``` 100 | ## 无序列表 101 | 102 | * 石头 103 | * 剪刀 104 | * 布 105 | 106 | ## 有序列表 107 | 108 | 1. 石头 109 | 2. 剪刀 110 | 3. 布 111 | ``` 112 | 113 | ![图9-2 列表预览](assets/1565878138608.png) 114 | 115 | #### 任务列表 116 | 117 | 在列表符号后面使用 [ ] 或 [x] 可以分别标记未完成或完成状态。例如: 118 | 119 | ``` 120 | ## 作业完成情况 121 | 122 | - [ ] 语文 123 | - [x] 数学 124 | - [ ] 物理 125 | - [ ] 英语 126 | - [x] 化学 127 | ``` 128 | 129 | 注意,标记未完成时括号内一定要有一个空格。 130 | 131 | ![图9-3 任务列表预览](assets/1565878216261.png) 132 | 133 | #### 代码块 134 | 135 | 代码块以 3 个符号 \` 起始(键盘上 \ 键下方的撇号),同样以 3 个 \` 结束。除了对代码格式比较友好,很多支持 Markdown 的工具、网站对代码块都自动高亮的功能。 136 | 137 | ~~~gfm 138 | 下面是一个例子: 139 | 140 | ``` 141 | def test(): 142 | print("Hello World!") 143 | ``` 144 | 145 | 146 | 语法高亮: 147 | 148 | ```python 149 | def test(): 150 | print("语法高亮") 151 | ``` 152 | ~~~ 153 | 154 | ![图9-4 代码块预览](assets/1565878297820.png) 155 | 156 | #### 数学块 157 | 158 | 有不少 Markdown 编辑器通过 MathJax 支持 LaTex 数学表达式。 159 | 160 | 数学公式使用两个美元符 \$\$ 开始和结束。 161 | 162 | ``` 163 | $$ 164 | \mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix} 165 | \mathbf{i} & \mathbf{j} & \mathbf{k} \\ 166 | \frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\ 167 | \frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \\ 168 | \end{vmatrix} 169 | $$ 170 | ``` 171 | 172 | 效果如下: 173 | 174 | ![图9-5 公式预览](assets/1565878448091.png) 175 | 176 | 这里只是展示 Markdown 支持这种数学公式,LaTex 语法本身读者需要参考其他资料学习使用。 177 | 178 | #### 表格 179 | 180 | 使用 |列1|列2| 就可以添加 2 列表格,标题行和内容行使用 |---| 进行分隔。 181 | 182 | ``` 183 | | 标题1 | 标题2 | 184 | | -------| ----- | 185 | | Cell1 | Cell3 | 186 | | Cell2 | Cell4 | 187 | ``` 188 | 189 | ![图9-6 表格预览](assets/1565878505816.png) 190 | 191 | 对齐可以通过对分隔行增加英文冒号 : 标记实现。 192 | 193 | ``` 194 | | 左对齐 | 中心对齐 | 右对齐 | 195 | | :----- |:-------:| -----:| 196 | | c1 | 这一列 | $16 | 197 | | c2 | 是中心 | $120 | 198 | | c3 | 对齐 | $11 | 199 | ``` 200 | 201 | ![图9-7 表格对齐预览](assets/1565878560237.png) 202 | 203 | #### 脚注 204 | 205 | ``` 206 | 你可以像这样添加脚注[^footnote]。 207 | 208 | [^footnote]: 这是一段脚注文字 209 | ``` 210 | 211 | 效果如下: 212 | 213 | ![图9-8 脚注预览](assets/1565878612454.png) 214 | 215 | 216 | #### 水平线 217 | 218 | 在空行中使用 \*\*\* 或者 --- 就可以生成一条水平分隔线。 219 | 220 | ### 9.2.2 内联元素 221 | 222 | #### 链接 223 | 224 | Markdown 支持行内和参考两种链接方式,链接的文字都是写在方括号内。 225 | 226 | 行内链接的写法如下: 227 | 228 | ``` 229 | [这个链接](https://baidu.com)会跳转到百度 230 | ``` 231 | 232 | ![图9-9 行内链接预览](assets/1565878849732.png) 233 | 234 | 参考链接的写法如下: 235 | 236 | ``` 237 | [这个链接][id]会跳转到百度 238 | 239 | [id]: https://baidu.com 240 | ``` 241 | 242 | ![图9-10 参考链接预览](assets/1565878886705.png) 243 | 244 | #### URL 245 | 246 | URL 使用 2 个尖括号将文本包围,与链接不同的是 URL 的显示的就是尖括号内的文字,不能自定义显示内容。 247 | 248 | 249 | ``` 250 | 251 | 252 | 253 | ``` 254 | 255 | ![图9-11 URL 预览](assets/1565878937914.png) 256 | 257 | 258 | #### 图片 259 | 260 | 图片跟链接相似,但是需要在链接的前面添加一个英文感叹号 ! 符号。 261 | 262 | ``` 263 | ![说明文字](图片路径.jpg) 264 | ![说明文字](图片路径.png) 265 | 266 | 例如: 267 | ![](https://www.baidu.com/img/dong_96c3c31cae66e61ed02644d732fcd5f8.gif) 268 | ``` 269 | 270 | ![图9-12 图片预览(图片来自网络)](assets/1565878990096.png) 271 | 272 | 273 | 274 | 路径可以是 URL,可以是计算机本地的绝对路径或相对路径。 275 | 276 | #### 强调与加粗 277 | 278 | Markdown 使用星号或下划线强调文字。 279 | 280 | ``` 281 | *使用星号* 282 | 283 | _使用下划线_ 284 | ``` 285 | 286 | *使用星号* 287 | 288 | _使用下划线_ 289 | 290 | 291 | 使用两个符号则是进行加粗。 292 | 293 | ``` 294 | **使用2个星号** 295 | 296 | __使用2个下划线__ 297 | ``` 298 | 299 | **使用2个星号** 300 | 301 | __使用2个下划线__ 302 | 303 | #### 删除线 304 | 305 | Markdown 使用2个波浪线 ~ 对文字进行删除标记。 306 | 307 | ``` 308 | ~~这是一段被删除线标记的文字~~ 309 | ``` 310 | 311 | ~~这是一段被删除线标记的文字~~ 312 | 313 | #### 下划线 314 | 315 | 下划线需要原生 HTML 标签支持。 316 | 317 | ``` 318 | 这段文字会被下划线标记 319 | ``` 320 | 321 | 这段文字会被下划线标记 322 | 323 | #### 上标与下标 324 | 325 | Markdown 下标使用单个波浪号 ~,上标使用 ^。下面写法可以创建水分子和 X 的平方。 326 | 327 | ``` 328 | H~2~O 329 | 330 | X^2^ 331 | ``` 332 | 333 | H~2~O 334 | 335 | X^2^ 336 | 337 | 338 | #### 行内代码 339 | 340 | 前面提到了代码块,但有时候代码很短,需要使用行内代码,这时候用单个的符号 \` 即可。 341 | 342 | ``` 343 | `x = y = 3` 344 | ``` 345 | 346 | `x = y = 3` 347 | 348 | #### 行内公式 349 | 350 | 行内公式使用单个美元符 \$ 开始和结束: 351 | 352 | ``` 353 | $y = a \times x + b$ 354 | ``` 355 | 356 | 效果如下: 357 | 358 | $y = a \times x + b$ 359 | 360 | 361 | ## 9.3 联合 Python 与 Markdown 362 | 363 | ### 9.3.1 代码块与文本块 364 | 365 | Notebook 支持两种不同的输入,一是代码块(这里我们指 Python 代码),二是文本块,即 Markdown 内容。 366 | 367 | 图9-13用 nteract 显示了一个代码块,点击右上方的菜单栏后,会出现多个选项。最后一个选项能够将代码块转变为文本块,点击后的结果如图9-14所示。 368 | 369 | ![图9-13 nteract 显示的代码块](assets/1565881098150.png) 370 | 371 | ![图9-14 nteract 显示的文本块](assets/1565881258155.png) 372 | 373 | 374 | 375 | Jupyter Notebook 支持的快捷键可能操作起来更轻松,m 键将代码块转换为文本块,而 y 键将文本块转换为代码块。 376 | 377 | 在我们了解代码块和文本块之后,我们就可以自由地使用它们编写动态的程序文档,即 Notebook。一般而言,我们使用 Markdown 标题构建文档的整个逻辑结构,使用正文和相关标记如链接等增加对文档、代码块的说明,利用代码块执行计算并展示文字结果或图形,一个简单的示例如图9-15所示。 378 | 379 | ![图9-15 Notebook 书写简单示例](assets/1565883426201.png) 380 | 381 | ### 9.3.2 文档范例 382 | 383 | 上节提到的 Markdown 语法内容颇多,它们虽然简单,但也需要时间学习和掌握。本节以 绘制引力波曲线 为题写一个简单的 Markdown 文章,以帮助读者对 Markdown 的整体使用有更深的了解。 384 | 385 | 下面是源代码: 386 | 387 | ~~~gfm 388 | # 绘制引力波曲线 389 | 390 | ## 数据下载与准备 391 | 392 | 第一个引力波文件:[H1_Strain.wav](http://python123.io/dv/H1_Strain.wav) (点击下载) 393 | 394 | 第二个引力波文件:[L1_Strain.wav](http://python123.io/dv/L1_Strain.wav) (点击下载) 395 | 396 | 引力波参考文件:[wf_template.txt](http://python123.io/dv/wf_template.txt) (点击后保存下载) 397 | 398 | 将上述文件下载到本地并保存到一个目录中,在该目录中创建一个 Notebook 文件,并依次运行下面的代码行。 399 | 400 | ## 导入包 401 | 402 | 本例需要使用到 3 个三方包,下面我们将它们依次导入。 403 | 404 | ```python 405 | import numpy as np 406 | import matplotlib.pyplot as plt 407 | from scipy.io import wavfile 408 | ``` 409 | 410 | ## 导入数据 411 | 412 | 接下来我们使用 scipy 包提供的函数导入引力波文件,使用 numpy 包提供的函数导入参考文件。 413 | 414 | ```python 415 | rate_h, hstrain= wavfile.read(r"H1_Strain.wav","rb") 416 | rate_l, lstrain= wavfile.read(r"L1_Strain.wav","rb") 417 | reftime, ref_H1 = np.genfromtxt('wf_template.txt').transpose() 418 | 419 | # 这里我们使用频率的倒数来确定波的周期 420 | htime_interval = 1/rate_h 421 | ltime_interval = 1/rate_l 422 | ``` 423 | 424 | ### 简单查看数据 425 | 426 | ```python 427 | # 使用 print() 函数对各项输入的数据进行简单的查看 428 | print(rate_h, hstrain) 429 | print(rate_l, lstrain) 430 | print(reftime, ref_H1) 431 | ``` 432 | 433 | ## 绘图 434 | 435 | ```python 436 | # 设定在 Notebook 中使用绘图 437 | %matplotlib inline 438 | ``` 439 | 440 | 接下来我们依次根据 2 个波文件和 1 个参考文件提供的数据绘制波形图,以子图的形式将它们绘制在一起。 441 | 442 | ```python 443 | htime_len = hstrain.shape[0]/rate_h 444 | htime = np.arange(-htime_len/2, htime_len/2 , htime_interval) 445 | plt.subplot(2,2,1) 446 | plt.plot(htime, hstrain, 'y') 447 | plt.xlabel('Time (seconds)') 448 | plt.ylabel('H1 Strain') 449 | plt.title('H1 Strain') 450 | 451 | ltime_len = lstrain.shape[0]/rate_l 452 | ltime = np.arange(-ltime_len/2, ltime_len/2 , ltime_interval) 453 | plt.subplot(2,2,2) 454 | plt.plot(ltime, lstrain, 'g') 455 | plt.xlabel('Time (seconds)') 456 | plt.ylabel('L1 Strain') 457 | plt.title('L1 Strain') 458 | 459 | plt.subplot(2, 1, 2) 460 | plt.plot(reftime, ref_H1) 461 | plt.xlabel('Time (seconds)') 462 | plt.ylabel('Template Strain') 463 | plt.title('Template') 464 | plt.tight_layout() 465 | ``` 466 | ~~~ 467 | 468 | 请读者下载所需文件后在同一目录下新建一个Jupyter Notebook,然后将代码放入代码块中,将文本内容放入文本块中然后运行查看效果,如图9-16、图9-17所示。 469 | 470 | ![图9-16 Notebook 示例(一)](assets/1565965546720.png) 471 | 472 | ![图9-17 Notebook 示例(二)](assets/1565965576073.png) 473 | 474 | 就这样,一篇联合 Python 和 Markdown 的动态文档就生成了。读者可以随时根据需要修改相应的文字或代码,然后对文档进行更新。然后,读者可以将文档导出为多种格式如 HTML、PDF 进行分享或者是汇报。 475 | 476 | 477 | ## 9.4 章末小结 478 | 479 | 数据分析是本书的核心主题,当下动态文档推动着更高效的分析报告和可重复性科学研究,Markdown 是动态文档的核心工具之一。本章简要地对 Markdown 基础语法进行了介绍,并为在实际工作中如何将 Markdown 与 Python 进行联合使用提供了范例。 480 | 481 | -------------------------------------------------------------------------------- /docs/12-advanced-pandas.assets/image-20191230003925736.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/12-advanced-pandas.assets/image-20191230003925736.png -------------------------------------------------------------------------------- /docs/12-advanced-pandas.assets/image-20191230004055880.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/12-advanced-pandas.assets/image-20191230004055880.png -------------------------------------------------------------------------------- /docs/12-advanced-pandas.assets/image-20191230004143103.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/12-advanced-pandas.assets/image-20191230004143103.png -------------------------------------------------------------------------------- /docs/12-advanced-pandas.assets/image-20191230004245577.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/12-advanced-pandas.assets/image-20191230004245577.png -------------------------------------------------------------------------------- /docs/12-advanced-pandas.assets/image-20191230004347306.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/12-advanced-pandas.assets/image-20191230004347306.png -------------------------------------------------------------------------------- /docs/12-advanced-pandas.assets/image-20191230004432888.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/12-advanced-pandas.assets/image-20191230004432888.png -------------------------------------------------------------------------------- /docs/12-advanced-pandas.assets/image-20191230004515958.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/12-advanced-pandas.assets/image-20191230004515958.png -------------------------------------------------------------------------------- /docs/12-advanced-pandas.assets/image-20191230004552654.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/12-advanced-pandas.assets/image-20191230004552654.png -------------------------------------------------------------------------------- /docs/12-advanced-pandas.assets/image-20191230004636247.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/12-advanced-pandas.assets/image-20191230004636247.png -------------------------------------------------------------------------------- /docs/12-advanced-pandas.assets/image-20191230004751906.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/12-advanced-pandas.assets/image-20191230004751906.png -------------------------------------------------------------------------------- /docs/12-advanced-pandas.assets/image-20191230004830637.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/12-advanced-pandas.assets/image-20191230004830637.png -------------------------------------------------------------------------------- /docs/12-advanced-pandas.assets/image-20191230004907721.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/12-advanced-pandas.assets/image-20191230004907721.png -------------------------------------------------------------------------------- /docs/12-advanced-pandas.assets/image-20191230004953542.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/12-advanced-pandas.assets/image-20191230004953542.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230215115722.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230215115722.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230215554306.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230215554306.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230215943127.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230215943127.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230220723864.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230220723864.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230220938667.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230220938667.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230221009007.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230221009007.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230221207470.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230221207470.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230221500314.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230221500314.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230221600624.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230221600624.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230221709623.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230221709623.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230221756287.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230221756287.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230222028538.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230222028538.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230222135759.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230222135759.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230222321813.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230222321813.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230222426218.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230222426218.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230222708685.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230222708685.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230223148915.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230223148915.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230223250156.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230223250156.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230223419554.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230223419554.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230223457527.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230223457527.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230223557348.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230223557348.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230223710925.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230223710925.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230223842550.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230223842550.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230224044284.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230224044284.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230224254356.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230224254356.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230224358512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230224358512.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230224528932.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230224528932.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230225221554.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230225221554.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230225458923.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230225458923.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230225647464.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230225647464.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230230129141.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230230129141.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230230214815.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230230214815.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191230230300868.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191230230300868.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/image-20191231001708117.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/image-20191231001708117.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/sns-add-cyl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/sns-add-cyl.png -------------------------------------------------------------------------------- /docs/13-advanced-vis.assets/sns-col3-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/13-advanced-vis.assets/sns-col3-7.png -------------------------------------------------------------------------------- /docs/14-stats.assets/1000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/14-stats.assets/1000.jpg -------------------------------------------------------------------------------- /docs/14-stats.assets/image-20191230232350998.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/14-stats.assets/image-20191230232350998.png -------------------------------------------------------------------------------- /docs/14-stats.assets/image-20191230232550894.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/14-stats.assets/image-20191230232550894.png -------------------------------------------------------------------------------- /docs/14-stats.assets/image-20191230233657424.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/14-stats.assets/image-20191230233657424.png -------------------------------------------------------------------------------- /docs/14-stats.assets/image-20191230234020193.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/14-stats.assets/image-20191230234020193.png -------------------------------------------------------------------------------- /docs/14-stats.assets/image-20191230234149623.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/14-stats.assets/image-20191230234149623.png -------------------------------------------------------------------------------- /docs/14-stats.assets/image-20191230234242528.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/14-stats.assets/image-20191230234242528.png -------------------------------------------------------------------------------- /docs/14-stats.assets/image-20191230234822443.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/14-stats.assets/image-20191230234822443.png -------------------------------------------------------------------------------- /docs/14-stats.assets/image-20191231003035336.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/14-stats.assets/image-20191231003035336.png -------------------------------------------------------------------------------- /docs/14-stats.assets/image-20191231003204811.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/14-stats.assets/image-20191231003204811.png -------------------------------------------------------------------------------- /docs/15-append.md: -------------------------------------------------------------------------------- 1 | # 第 15 章 未言及的内容 2 | 3 | **本章内容提要**: 4 | 5 | - 魔术命令 6 | - 面向对象编程 7 | 8 | 本章作为全书的最后一个章节,附加介绍两个未言及但可能有用的内容:第一个是 IPython 的魔术命令,第二个是面向对象编程知识。 9 | 10 | ## 15.1 魔术命令 11 | 12 | 魔术命令是 IPython 在 Python 语法基础上增强的功能,一般以 % 作为前缀,魔术命令用于简洁地解决标准数据分析中的各种常见问题,如列出当前目录文件,运行脚本。 13 | 14 | 下面列出了一些常见的魔术命令和它的描述。 15 | 16 | ```python 17 | %paste # 粘贴代码 18 | %run # 执行外部脚本 19 | %timeit # 计算代码运行时间 20 | %magic # 获取可用魔术命令描述与示例 21 | %lsmagic # 获取可用魔术命令列表 22 | %ls # 列出当前目录列表 23 | %pwd # 获取当前所在(工作)目录 24 | %cd # 切换工作目录 25 | %mkdir # 创建文件夹 26 | %cp # 拷贝文件 27 | %rm # 删除文件 28 | ``` 29 | 30 | 魔术命令相当有用,它解决了数据分析时想要实时与系统进行交互并测试代码的痛点。 31 | 32 | 在 IPython Shell 或 Jupyter Notebook 中输入 %lsmagic 即可查看所有的魔术命令。 33 | 34 | ```python 35 | In [4]: %lsmagic 36 | Out[4]: 37 | Available line magics: 38 | %alias %alias_magic %autoawait %autocall %autoindent %automagic %bookmark %cat %cd %clear %colors %conda %config %cp %cpaste %debug %dhist %dirs %doctest_mode %ed %edit %env %gui %hist %history %killbgscripts %ldir %less %lf %lk %ll %load %load_ext %loadpy %logoff %logon %logstart %logstate %logstop %ls %lsmagic %lx %macro %magic %m 39 | an %matplotlib %mkdir %more %mv %notebook %page %paste %pastebin %pdb %pdef %pdoc %pfile %pinfo %pinfo2 %pip %popd %pprint %precision %prun %psearch %psource %pushd % 40 | pwd %pycat %pylab %quickref %recall %rehashx %reload_ext %rep %rerun %reset %reset_selective %rm %rmdir %run %save %sc %set_env %store %sx %system %tb %time %timeit % 41 | unalias %unload_ext %who %who_ls %whos %xdel %xmode 42 | 43 | Available cell magics: 44 | %%! %%HTML %%SVG %%bash %%capture %%debug %%file %%html %%javascript %%js %%latex %%markdown %%perl %%prun %%pypy %%python %%python2 %%python3 %%ruby %%script %%sh %%sv 45 | g %%sx %%system %%time %%timeit %%writefile 46 | 47 | Automagic is ON, % prefix IS NOT needed for line magics. 48 | ``` 49 | 50 | 一般而言,魔术命令的作用可以通过名字进行猜测。如果我们不确定,可以在后面跟一个问号查看对应的文档。 51 | 52 | ```python 53 | In [5]: %ls? 54 | Repr: 55 | ``` 56 | 57 | 结果显示 %ls 命令是 ls -F 命令的缩写,ls 命令是 Unix 系统进行文件管理的命令之一,用于查看目录下的文件列表。其他的 Unix 命令都有魔术命令的相应实现,包括 mkdir、cp、pwd 等。 58 | 59 | 运行 %ls 命令,发现当前目录下没有任何文件或目录。 60 | 61 | ```python 62 | In [6]: %ls 63 | 64 | ``` 65 | 66 | 我们使用 %mkdir 创建一个目录 new 再次进行检查。 67 | 68 | ```python 69 | In [7]: %mkdir new 70 | In [8]: %ls 71 | new/ 72 | ``` 73 | 74 | 使用 %pwd 查看我们工作目录在操作系统中的位置。 75 | 76 | ```python 77 | In [9]: %pwd 78 | Out[9]: '/home/shixiang/Proj/pybook/test_ipython_shell' 79 | ``` 80 | 81 | 使用 %cd 切换到另一个目录,如上面新建的 new 目录。 82 | 83 | ```python 84 | In [10]: %cd new 85 | /home/shixiang/Proj/pybook/test_ipython_shell/new 86 | In [11]: %pwd 87 | Out[11]: '/home/shixiang/Proj/pybook/test_ipython_shell/new' 88 | ``` 89 | 90 | %timeit 是一个非常有用的魔术命令,它可以计算 Python 代码的执行时间。 91 | 92 | ```python 93 | In [12]: %timeit Result = [i ** 2 for i in range(100)] 94 | 47.6 µs ± 386 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each) 95 | ``` 96 | 97 | 该命令会自动多次执行命令(10000 次)以获得稳定的结果,当使用多行输入时我们需要对命令多加一个百分号。 98 | 99 | ```python 100 | In [13]: %%timeit 101 | ...: Result = [] 102 | ...: for i in range(100): 103 | ...: Result.append(i * i) 104 | ...: 105 | 16.7 µs ± 178 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each) 106 | ``` 107 | 108 | ## 15.2 面向对象编程 109 | 110 | 面向对象编程(object-oriented programming,OOP)是许多编程语言都有的特性,Python 也不例外。 111 | 不过,数据处理和分析时我们一般很少自己创建自定义的类,除非是开发一些数据处理工具软件,用类来表示一些核心的数据结构,如 Pandas 库的 DataFrame。 112 | 本节向读者简单介绍面向对象编程的一些基本概念和操作方法,以便于读者能够了解这一前面遗漏的 Python 基础知识。 113 | 114 | 面向对象的核心概念是类(Class)和实例或对象(Object),类是对象的蓝图,对象是类的实例化。如学生是一个类,某学生小周就是一个对象。 115 | 116 | 我们假设学生有名字、年龄、身高和成绩 4 个属性,使用 Python 创建一个 Student 类如下: 117 | 118 | ```python 119 | In [1]: class Student: 120 | ...: def __init__(self, name, age, height, score): 121 | ...: self.name = name 122 | ...: self.age = age 123 | ...: self.height = height 124 | ...: self.score = score 125 | ``` 126 | 127 | 有了类以后,我们可以创建不同的学生实例,如小周、小张、小李等等。 128 | 129 | 类中定义的函数称为方法,每个类都需要一个 \_\_init\_\_() 函数用于初始化。类的方法第一个参数永远是 self,指向其本身。 130 | 后续的参数就是用户可以实际输入的参数,我们按照格式就可以创建一个对象。 131 | 132 | ```python 133 | In [2]: Student('小周', 20, 180, 98) 134 | Out[2]: <__main__.Student at 0x7fe95c4eeb50> 135 | ``` 136 | 137 | 在方法中我们可以执行计算或者将一些数据存储起来,存储数据的变量称为类的属性。如初始化函数中的 self.name、self.age 等。 138 | 139 | 当我们创建好一个对象后,我们可以使用成员操作符获取对象的属性值。 140 | 141 | ```python 142 | In [3]: zhou = Student('小周', 20, 180, 98) 143 | In [4]: zhou.score 144 | Out[4]: 98 145 | In [5]: zhou.height 146 | Out[5]: 180 147 | In [6]: zhou.age 148 | Out[6]: 20 149 | ``` 150 | 151 | 除了初始化方法,我们还可以定义其他方法进行计算。例如某班级的平均分为 70 分,我们定义一个方法计算 152 | 小周成绩与班级平均分的差值。 153 | 154 | 我们先为 Student 类加上计算差值的方法: 155 | 156 | ```python 157 | In [7]: class Student: 158 | ...: def __init__(self, name, age, height, score): 159 | ...: self.name = name 160 | ...: self.age = age 161 | ...: self.height = height 162 | ...: self.score = score 163 | ...: def diff(self, average_score): 164 | ...: print(self.score - average_score) 165 | ...: 166 | ``` 167 | 168 | 重新创建对象 zhou: 169 | 170 | ```python 171 | zhou = Student('小周', 20, 180, 98) 172 | ``` 173 | 174 | 计算差值: 175 | 176 | ```python 177 | In [9]: zhou.diff(70) 178 | 28 179 | ``` 180 | 181 | 基于上面的知识,我们可以根据自己的需要创建类并添加任意多的属性和方法。 182 | 183 | 面向对象编程还有一个比较重要的概念是继承(Inheritance),它可以有效地代表不同类的层级 184 | 关系和重用代码。 185 | 186 | 例如,上面我们以及创建了一个 Student 类,现在我们想要创建一个 Studnet2 类,该类在 Student 187 | 类的基础上多了两个属性 class_name 和 teacher_name 用来表示班级名和班主任名字。 188 | 189 | 实现代码如下: 190 | 191 | ```python 192 | In [15]: class Student2(Student): 193 | ...: def __init__(self, name, age, height, score, class_name, teacher_name): 194 | ...: Student.__init__(self, name, age, height, score) 195 | ...: self.class_name = class_name 196 | ...: self.teacher_name = teacher_name 197 | ...: 198 | ``` 199 | 200 | 注意,在新的类初始化方法中,我们需要调用 Student 类的初始化。接着我们重新创建一个新的对象 zhou。 201 | 202 | ```python 203 | In [16]: zhou = Student2('小周', 20, 180, 98, "Class A", "Mr. Zhang") 204 | ``` 205 | 206 | 我们依然可以使用 Student 类的属性和方法。 207 | 208 | ```python 209 | In [17]: zhou.name 210 | Out[17]: '小周' 211 | In [18]: zhou.diff(70) 212 | 28 213 | ``` 214 | 215 | ## 15.3 章末小结 216 | 217 | 本章介绍了 IPython 魔术命令和面向对象编程两个补充内容。了解和掌握常见的魔术命令是非常有用的, 218 | 它可以辅助读者快速地与操作系统进行交互、完成一些常见任务。面向对象编程则提供了新的编程视角, 219 | 虽然自定义类在数据分析中不常用,但它依然适用于解决一些特定的问题,以及辅助读者了解常见分析库中 220 | 一些类的使用,如 NumPy 中的 ndarray 和 Pandas 中的 DataFrame。 221 | -------------------------------------------------------------------------------- /docs/16-end.md: -------------------------------------------------------------------------------- 1 | # 结语:接下来学什么 2 | 3 | 数据分析在商业决策,云计算、生物医学科研等领域正扮演越来越重要的角色。本书包含了需要利用 Python 进行数据处理的基本知识,有 Python 基础编程知识、Python 数据导入与操作、Python 可视化以及基本的统计知识等 。本书虽然用了十几章的篇幅对这些知识点进行介绍,但仍有众多知识点未能涵盖或深入。在学习了本书,有了 Python 编程和数据分析的基础后,本书推荐读者根据自己的业务更加深入地去学习和应用 Python 数据分析技能,让知识变得有用,才能更好地理解和掌握知识。 4 | 5 | 下面按分类罗列了一些能够帮助读者进阶的技术书籍。 6 | 7 | #### Python 编程 8 | 9 | - 廖雪峰的《Python 3 基础教程》 10 | - 《Python 学习手册》 11 | - 《流畅的 Python》 12 | 13 | #### Python 数据分析 14 | 15 | - 《利用 Python 进行数据处理》 16 | - 《Python 数据科学手册》 17 | - 《Python 数据分析实战》 18 | 19 | #### 统计学 20 | 21 | - 《统计学七支柱》 22 | - 《统计数字会撒谎》 23 | - 《Python 统计分析》 24 | 25 | #### 可视化 26 | 27 | - 《Python 数据可视化编程实战》 28 | - 《Python 数据可视化》 29 | - 《ggplot2:数据分析与图形艺术》 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /docs/QA.md: -------------------------------------------------------------------------------- 1 | # 2020-01-13 2 | 3 | ## 1 4 | 5 | 这里去掉下面一段话后面的内容 6 | 7 | > 这种特性叫做序列解包,将多个值的序列解开,然后放到左侧的变量序列中。当函数或者方法返回元组(或其他可迭代对象)时,这个操作尤为有用。 8 | 9 | 并更改为: 10 | 11 | ```python 12 | def func(): 13 | a = 1 14 | b = 2 15 | c = 3 16 | return a, b, c 17 | 18 | # 序列解包操作: 19 | # 将函数结果直接赋值到多个变量中 20 | # 按顺序一一对应 21 | # d <- a 22 | # e <- b 23 | # f <- c 24 | d, e, f = func() 25 | ``` 26 | 27 | 等号两侧元素数量要一致,否则会报错。上述序列解包操作精简了下面的代码并提升了计算效率: 28 | 29 | ```python 30 | # 获取一个元组结果 31 | tup_res = func() 32 | # 分别赋值 33 | d = tup_res[0] 34 | e = tup_res[1] 35 | f = tup_res[2] 36 | ``` 37 | 38 | ## 2 11.7 节章末小结和这一章开始的介绍语完全重复,请重新写一下。 39 | 40 | 本章的内容较为驳杂,以工具箱的方式提供了一些 Python 编程的便利函数和操作技巧,包括异常捕获、函数式编程和正则表达式等。理解和掌握这些知识有助于读者更好地理解 Python,编写安全高效的代码。 41 | 42 | ## 3 13.3.1节,“步骤2”指代什么? 43 | 44 | 指代码逻辑步骤,在代码注释中有标注 45 | 46 | ## 4 14.1.1 横线处“都有计算实现”,看不懂是什么意思,请重新整理语言 47 | 48 | 修改如下: 49 | 50 | Python 标准库、NumPy 库 和 Pandas 库都提供了相应的计算函数。 51 | 52 | ## 5 几何平均数 53 | 54 | 几何平均数是 n 个数值乘积的 n 次根。 -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /docs/assets/1565877938229.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565877938229.png -------------------------------------------------------------------------------- /docs/assets/1565878138608.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565878138608.png -------------------------------------------------------------------------------- /docs/assets/1565878216261.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565878216261.png -------------------------------------------------------------------------------- /docs/assets/1565878297820.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565878297820.png -------------------------------------------------------------------------------- /docs/assets/1565878448091.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565878448091.png -------------------------------------------------------------------------------- /docs/assets/1565878505816.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565878505816.png -------------------------------------------------------------------------------- /docs/assets/1565878560237.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565878560237.png -------------------------------------------------------------------------------- /docs/assets/1565878612454.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565878612454.png -------------------------------------------------------------------------------- /docs/assets/1565878849732.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565878849732.png -------------------------------------------------------------------------------- /docs/assets/1565878886705.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565878886705.png -------------------------------------------------------------------------------- /docs/assets/1565878937914.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565878937914.png -------------------------------------------------------------------------------- /docs/assets/1565878990096.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565878990096.png -------------------------------------------------------------------------------- /docs/assets/1565881098150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565881098150.png -------------------------------------------------------------------------------- /docs/assets/1565881258155.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565881258155.png -------------------------------------------------------------------------------- /docs/assets/1565883426201.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565883426201.png -------------------------------------------------------------------------------- /docs/assets/1565965546720.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565965546720.png -------------------------------------------------------------------------------- /docs/assets/1565965576073.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565965576073.png -------------------------------------------------------------------------------- /docs/assets/1565968443953.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1565968443953.png -------------------------------------------------------------------------------- /docs/assets/1566008307111.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566008307111.png -------------------------------------------------------------------------------- /docs/assets/1566009197372.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566009197372.png -------------------------------------------------------------------------------- /docs/assets/1566009715829.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566009715829.png -------------------------------------------------------------------------------- /docs/assets/1566009847601.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566009847601.png -------------------------------------------------------------------------------- /docs/assets/1566010077143.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566010077143.png -------------------------------------------------------------------------------- /docs/assets/1566010369211.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566010369211.png -------------------------------------------------------------------------------- /docs/assets/1566010491532.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566010491532.png -------------------------------------------------------------------------------- /docs/assets/1566010624845.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566010624845.png -------------------------------------------------------------------------------- /docs/assets/1566010719188.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566010719188.png -------------------------------------------------------------------------------- /docs/assets/1566010869416.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566010869416.png -------------------------------------------------------------------------------- /docs/assets/1566011014665.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566011014665.png -------------------------------------------------------------------------------- /docs/assets/1566011155999.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566011155999.png -------------------------------------------------------------------------------- /docs/assets/1566011228901.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566011228901.png -------------------------------------------------------------------------------- /docs/assets/1566011365121.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566011365121.png -------------------------------------------------------------------------------- /docs/assets/1566011464100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566011464100.png -------------------------------------------------------------------------------- /docs/assets/1566011545524.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566011545524.png -------------------------------------------------------------------------------- /docs/assets/1566011646740.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566011646740.png -------------------------------------------------------------------------------- /docs/assets/1566011764310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566011764310.png -------------------------------------------------------------------------------- /docs/assets/1566011842818.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566011842818.png -------------------------------------------------------------------------------- /docs/assets/1566011901725.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566011901725.png -------------------------------------------------------------------------------- /docs/assets/1566012009692.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566012009692.png -------------------------------------------------------------------------------- /docs/assets/1566012156747.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566012156747.png -------------------------------------------------------------------------------- /docs/assets/1566012247119.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566012247119.png -------------------------------------------------------------------------------- /docs/assets/1566012427766.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566012427766.png -------------------------------------------------------------------------------- /docs/assets/1566012512679.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566012512679.png -------------------------------------------------------------------------------- /docs/assets/1566012584741.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566012584741.png -------------------------------------------------------------------------------- /docs/assets/1566012743480.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566012743480.png -------------------------------------------------------------------------------- /docs/assets/1566012814718.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566012814718.png -------------------------------------------------------------------------------- /docs/assets/1566013182248.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566013182248.png -------------------------------------------------------------------------------- /docs/assets/1566013434471.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566013434471.png -------------------------------------------------------------------------------- /docs/assets/1566013535017.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566013535017.png -------------------------------------------------------------------------------- /docs/assets/1566013707092.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566013707092.png -------------------------------------------------------------------------------- /docs/assets/1566029014148.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566029014148.png -------------------------------------------------------------------------------- /docs/assets/1566029142554.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566029142554.png -------------------------------------------------------------------------------- /docs/assets/1566029266277.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566029266277.png -------------------------------------------------------------------------------- /docs/assets/1566029521952.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566029521952.png -------------------------------------------------------------------------------- /docs/assets/1566029603380.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566029603380.png -------------------------------------------------------------------------------- /docs/assets/1566030049989.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566030049989.png -------------------------------------------------------------------------------- /docs/assets/1566030181185.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566030181185.png -------------------------------------------------------------------------------- /docs/assets/1566030359191.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566030359191.png -------------------------------------------------------------------------------- /docs/assets/1566030513027.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566030513027.png -------------------------------------------------------------------------------- /docs/assets/1566030610383.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566030610383.png -------------------------------------------------------------------------------- /docs/assets/1566030719209.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566030719209.png -------------------------------------------------------------------------------- /docs/assets/1566030891387.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566030891387.png -------------------------------------------------------------------------------- /docs/assets/1566031061659.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566031061659.png -------------------------------------------------------------------------------- /docs/assets/1566031144809.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566031144809.png -------------------------------------------------------------------------------- /docs/assets/1566031232055.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566031232055.png -------------------------------------------------------------------------------- /docs/assets/1566031500991.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/1566031500991.png -------------------------------------------------------------------------------- /docs/assets/Gravitational_Waves_Original.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/assets/Gravitational_Waves_Original.png -------------------------------------------------------------------------------- /docs/author-and-recommendation/ShixiangWang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/author-and-recommendation/ShixiangWang.png -------------------------------------------------------------------------------- /docs/author-and-recommendation/todo.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/author-and-recommendation/todo.docx -------------------------------------------------------------------------------- /docs/author-and-recommendation/todo.md: -------------------------------------------------------------------------------- 1 | 1)全书要点思维脑图 2 | 2)作者简介+照片 3 | 3)后勒口文案 4 | 5 | 否总结一下本书的要点,用类似思维脑图的那种形式 6 | 7 | 前勒口需要放作者简介(100-200字)、作者照片(非必须,最好是有) 8 | 9 | 后勒口可以放作者想对读者说的话,或者读者看完本书后该怎么继续学习 10 | 11 | 12 | 13 | ## 1 思维导图 14 | 15 | 见图 16 | 17 | 18 | 19 | ## 2 作者简介 20 | 21 | 王诗翔(GitHub@ShixiangWang),2016 年成都电子科技大学本科毕业,开源爱好者与开发者,简书互联网优秀作者。他目前从事生物信息学在肿瘤精准医疗方向的研究工作,并在数个国际知名期刊上发表 SCI 论文。他掌握 Python、R、Shell 等多门与数据处理相关的编程语言以及各类数据分析和统计技术,对技术知识的分享和传播充满热情。 22 | 23 | ## 3 对读者说的话 24 | 25 | 作为 21 世纪最性感的职业,数据科学家的背后需要超乎常人的付出,他要构建业务逻辑思维、修炼数理统计内功、打造编程利器,然后不断实践和更新技能。我在本书中以粗浅的内容尝试引导各位初学者去接触、了解、学习和掌握这个职业中一些基础的概念和技能。在学习本书内容之后,我希望各位读者不要畏惧接下来迎门而上的挑战,能够敢于和勇于在自己实际的工作场景中思考和应用所学,不断地学习和进阶。在遇到困难时,读者应当常常通过搜索引擎动手查找和解决问题,还可以通过一些专业问答社区和论坛与他人进行交流讨论。学习之路是快乐的,也是痛苦的,祝愿各位读者能在这个性感的职业中尽用所学,并乐在其中。 -------------------------------------------------------------------------------- /docs/author-and-recommendation/交互的Python - 思维导图.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/author-and-recommendation/交互的Python - 思维导图.pdf -------------------------------------------------------------------------------- /docs/author-and-recommendation/交互的Python - 思维导图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/author-and-recommendation/交互的Python - 思维导图.png -------------------------------------------------------------------------------- /docs/author.md: -------------------------------------------------------------------------------- 1 | # 作者 2 | 3 | ![](author-and-recommendation/ShixiangWang.png) 4 | 5 | 王诗翔(GitHub@ShixiangWang),2016 年成都电子科技大学本科毕业,开源爱好者与开发者,简书互联网优秀作者。他目前从事生物信息学在肿瘤精准医疗方向的研究工作,并在数个国际知名期刊上发表 SCI 论文。他掌握 Python、R、Shell 等多门与数据处理相关的编程语言以及各类数据分析和统计技术,对技术知识的分享和传播充满热情。 6 | 7 | -------------------------------------------------------------------------------- /docs/code/01-introduction.txt: -------------------------------------------------------------------------------- 1 | ```shell 2 | # 除了使用浏览器,也可以通过终端运行以下命令下载 Anaconda 3 | # wget -c https://repo.anaconda.com/archive/Anaconda3-2018.12-Linux-x86_64.sh 4 | 5 | # 添加执行权限 6 | chmod u+x Anaconda3-2018.12-Linux-x86_64.sh 7 | # 执行安装 8 | ./Anaconda3-2018.12-Linux-x86_64.sh 9 | 10 | # 也可以直接使用Bash进行安装 11 | bash Anaconda3-2018.12-Linux-x86_64.sh 12 | ``` 13 | ```shell 14 | jupyter notebook 15 | ``` 16 | -------------------------------------------------------------------------------- /docs/code/02-base.txt: -------------------------------------------------------------------------------- 1 | ``` 2 | Python 3.7.0 (default, Jun 28 2018, 07:39:16) 3 | [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin 4 | Type "help", "copyright", "credits" or "license" for more information. 5 | >>> 6 | ``` 7 | ``` 8 | Python 3.7.0 (default, Jun 28 2018, 07:39:16) 9 | Type 'copyright', 'credits' or 'license' for more information 10 | IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help. 11 | 12 | In [1]: 13 | ``` 14 | ```python 15 | print('你好啊,世界!) 16 | print('你好啊,世界')! 17 | ``` 18 | ```python 19 | 3 + 2 # 加法 20 | 3 / 2 # 浮点数除法 21 | 3 // 2 # 整除 22 | 3 * 2 # 乘法 23 | 3 ** 2 # 指数(幂) 24 | 3 % 2 # 求余 25 | abs(a) # 绝对值 26 | ``` 27 | ```python 28 | In [3]: 1 + 1 29 | Out[3]: 2 30 | 31 | In [4]: 1 - 1 32 | Out[4]: 0 33 | 34 | In [5]: 1 * 1 35 | Out[5]: 1 36 | 37 | In [6]: 1 / 1 38 | Out[6]: 1.0 39 | ``` 40 | ```python 41 | In [11]: 70 / 1.82 ** 2 42 | Out[11]: 21.132713440405748 43 | ``` 44 | ```python 45 | In [12]: 70 / 1.82 ** 2 # 计算我的 BMI 46 | Out[12]: 21.132713440405748 47 | ``` 48 | ```python 49 | In [13]: # 计算我的 BMI 50 | In [14]: 70 / 1.82 ** 2 51 | Out[14]: 21.132713440405748 52 | In [15]: # 计算我的 BMI 70 / 1.82 ** 2 53 | ``` 54 | ```python 55 | In [16]: 计算我的 BMI 指数 70 / 1.82 ** 2 56 | File "", line 1 57 | 计算我的 BMI 指数 70 / 1.82 ** 2 58 | ^ 59 | SyntaxError: invalid syntax 60 | ``` 61 | ```python 62 | In [9]: # 与朋友比较 BMI 指数 63 | In [10]: 70 / 1.82 ** 2 64 | Out[10]: 21.132713440405748 65 | 66 | In [11]: 48 / 1.64 ** 2 67 | Out[11]: 17.846519928613922 68 | 69 | In [12]: 70 / 1.82 ** 2 - 48 / 1.64 ** 2 70 | Out[12]: 3.2861935117918257 71 | ``` 72 | ```python 73 | In [13]: height = 1.82 74 | 75 | In [14]: weight = 70 76 | ``` 77 | ```python 78 | In [15]: print(height) 79 | Out[15]: 1.82 80 | 81 | In [16]: print(weight) 82 | Out[16]: 70 83 | 84 | In [17]: height 85 | Out[17]: 1.82 86 | 87 | In [18]: weight 88 | Out[18]: 70 89 | ``` 90 | ```python 91 | In [19]: myBMI = 70 / 1.82 ** 2 # 我的 BMI 92 | In [20]: friendBMI = 48 / 1.64 ** 2 # 朋友的 BMI 93 | In [21]: myBMI - friendBMI # 我与朋友的 BMI 值的差异 94 | Out[21]: 3.2861935117918257 95 | ``` 96 | ```python 97 | In [22]: __myName = "ShixiangWang" 98 | 99 | In [23]: my-name = "ShixiangWang" 100 | File "", line 1 101 | my-name = "ShixiangWang" 102 | ^ 103 | SyntaxError: can't assign to operator 104 | ``` 105 | ```python 106 | '''This is a multi-line string. This is the first line. 107 | This is the second line. 108 | "What's your name?," I asked. 109 | He said "Bond, James Bond." 110 | ''' 111 | ``` 112 | ```python 113 | In [26]: 'What's your name?' # 错误的表示方法 114 | File "", line 1 115 | 'What's your name?' # 错误的表示方法 116 | ^ 117 | SyntaxError: invalid syntax 118 | 119 | In [27]: 'What\'s your name?' # 使用转义\对字符串中的英文单引号进行转义 120 | Out[27]: "What's your name?" 121 | In [28]: "What\'s your name?" # 将英文单引号嵌入英文双引号中 122 | Out[28]: "What's your name?" 123 | ``` 124 | ```python 125 | "This is the first sentence.\ 126 | This is the second sentence." 127 | ``` 128 | ```python 129 | In [35]: "Newlines are indicated by \n" 130 | Out[35]: 'Newlines are indicated by \n' 131 | 132 | In [36]: r"Newlines are indicated by \n" 133 | Out[36]: 'Newlines are indicated by \\n' 134 | 135 | In [37]: print(r"Newlines are indicated by \n") 136 | Out[37]: Newlines are indicated by \n 137 | 138 | In [38]: print("Newlines are indicated by \n") 139 | Out[38]: Newlines are indicated by 140 | # 此处输出一个空行 141 | ``` 142 | ```python 143 | In [45]: type1 = 1 144 | In [46]: type2 = 1.0 145 | In [47]: type3 = "1" 146 | In [48]: type4 = True 147 | ``` 148 | ```python 149 | In [49]: type(type1) 150 | Out[49]: int 151 | In [50]: type(type2) 152 | Out[50]: float 153 | In [51]: type(type3) 154 | Out[51]: str 155 | In [52]: type(type4) 156 | Out[52]: bool 157 | ``` 158 | ```python 159 | In [2]: '1' + '1' 160 | Out[2]: '11' 161 | ``` 162 | ```python 163 | In [3]: '1' - '1' 164 | --------------------------------------------------------------------------- 165 | TypeError Traceback (most recent call last) 166 | in () 167 | ----> 1 '1' - '1' 168 | 169 | TypeError: unsupported operand type(s) for -: 'str' and 'str' 170 | ``` 171 | ```python 172 | In [8]: type('1') 173 | Out[8]: str 174 | 175 | In [9]: type(int('1')) 176 | Out[9]: int 177 | ``` 178 | ```python 179 | In [10]: "我的语文和数学成绩之和是 " + 199 180 | --------------------------------------------------------------------------- 181 | TypeError Traceback (most recent call last) 182 | in () 183 | ----> 1 "我的语文和数学成绩之和是 " + 199 184 | 185 | TypeError: must be str, not int 186 | 187 | In [11]: "我的语文和数学成绩之和是 " + str(199) 188 | Out[11]: '我的语文和数学成绩之和是 199' 189 | ``` 190 | ```python 191 | 9 + 2 # 加 192 | 9 - 2 # 减 193 | 9 * 2 # 乘 194 | 9 / 2 # 除(浮点输出) 195 | 9 //2 # 整除 196 | 9 % 2 # 求余 197 | 9 **2 # 幂 198 | ``` 199 | ```python 200 | '这是一个' + '字符串' # 字符串连接 201 | '这是一个字符串' * 5 # 字符串重复 202 | ``` 203 | ```python 204 | 5 == 4 # 等于 205 | 5 > 4 # 大于 206 | 5 < 4 # 小于 207 | 5 != 4 # 不等于 208 | 5 >= 4 # 大于或等于 209 | 5 <= 4 # 小于或等于 210 | ``` 211 | ```python 212 | True and True # 逻辑“与” 213 | True or False # 逻辑“或” 214 | not False # 逻辑“非” 215 | ``` 216 | -------------------------------------------------------------------------------- /docs/code/09-markdown.txt: -------------------------------------------------------------------------------- 1 | ``` 2 | 这是第一段话 3 | 4 | 这是第二段话 5 | ``` 6 | ``` 7 | 这是第一句话。 8 | 这是第二句话。 9 | ``` 10 | ``` 11 | # 这是一级标题 12 | 13 | ## 这是二级标题 14 | 15 | ### 这是三级标题 16 | 17 | #### 这是四级标题 18 | 19 | ##### 这是五级标题 20 | 21 | ###### 这是六级标题 22 | ``` 23 | ``` 24 | > 这里有3段引用,前面2段引用是在一起的,最后一段引用是独立的。 25 | > 26 | > 这是第2段引用。 27 | 28 | 29 | > 这是第3段引用。 30 | ``` 31 | ``` 32 | ## 无序列表 33 | 34 | * 石头 35 | * 剪刀 36 | * 布 37 | 38 | ## 有序列表 39 | 40 | 1. 石头 41 | 2. 剪刀 42 | 3. 布 43 | ``` 44 | ``` 45 | ## 作业完成情况 46 | 47 | - [ ] 语文 48 | - [x] 数学 49 | - [ ] 物理 50 | - [ ] 英语 51 | - [x] 化学 52 | ``` 53 | ``` 54 | def test(): 55 | print("Hello World!") 56 | ``` 57 | ```python 58 | def test(): 59 | print("语法高亮") 60 | ``` 61 | ``` 62 | $$ 63 | \mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix} 64 | \mathbf{i} & \mathbf{j} & \mathbf{k} \\ 65 | \frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\ 66 | \frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \\ 67 | \end{vmatrix} 68 | $$ 69 | ``` 70 | ``` 71 | | 标题1 | 标题2 | 72 | | -------| ----- | 73 | | Cell1 | Cell3 | 74 | | Cell2 | Cell4 | 75 | ``` 76 | ``` 77 | | 左对齐 | 中心对齐 | 右对齐 | 78 | | :----- |:-------:| -----:| 79 | | c1 | 这一列 | $16 | 80 | | c2 | 是中心 | $120 | 81 | | c3 | 对齐 | $11 | 82 | ``` 83 | ``` 84 | 你可以像这样添加脚注[^footnote]。 85 | 86 | [^footnote]: 这是一段脚注文字 87 | ``` 88 | ``` 89 | [这个链接](https://baidu.com)会跳转到百度 90 | ``` 91 | ``` 92 | [这个链接][id]会跳转到百度 93 | 94 | [id]: https://baidu.com 95 | ``` 96 | ``` 97 | 98 | 99 | 100 | ``` 101 | ``` 102 | ![说明文字](图片路径.jpg) 103 | ![说明文字](图片路径.png) 104 | 105 | 例如: 106 | ![](https://www.baidu.com/img/dong_96c3c31cae66e61ed02644d732fcd5f8.gif) 107 | ``` 108 | ``` 109 | *使用星号* 110 | 111 | _使用下划线_ 112 | ``` 113 | ``` 114 | **使用2个星号** 115 | 116 | __使用2个下划线__ 117 | ``` 118 | ``` 119 | ~~这是一段被删除线标记的文字~~ 120 | ``` 121 | ``` 122 | 这段文字会被下划线标记 123 | ``` 124 | ``` 125 | H~2~O 126 | 127 | X^2^ 128 | ``` 129 | ``` 130 | `x = y = 3` 131 | ``` 132 | ``` 133 | $y = a \times x + b$ 134 | ``` 135 | ```python 136 | import numpy as np 137 | import matplotlib.pyplot as plt 138 | from scipy.io import wavfile 139 | ``` 140 | ```python 141 | rate_h, hstrain= wavfile.read(r"H1_Strain.wav","rb") 142 | rate_l, lstrain= wavfile.read(r"L1_Strain.wav","rb") 143 | reftime, ref_H1 = np.genfromtxt('wf_template.txt').transpose() 144 | 145 | # 这里我们使用频率的倒数来确定波的周期 146 | htime_interval = 1/rate_h 147 | ltime_interval = 1/rate_l 148 | ``` 149 | ```python 150 | # 使用 print() 函数对各项输入的数据进行简单的查看 151 | print(rate_h, hstrain) 152 | print(rate_l, lstrain) 153 | print(reftime, ref_H1) 154 | ``` 155 | ```python 156 | # 设定在 Notebook 中使用绘图 157 | %matplotlib inline 158 | ``` 159 | ```python 160 | htime_len = hstrain.shape[0]/rate_h 161 | htime = np.arange(-htime_len/2, htime_len/2 , htime_interval) 162 | plt.subplot(2,2,1) 163 | plt.plot(htime, hstrain, 'y') 164 | plt.xlabel('Time (seconds)') 165 | plt.ylabel('H1 Strain') 166 | plt.title('H1 Strain') 167 | 168 | ltime_len = lstrain.shape[0]/rate_l 169 | ltime = np.arange(-ltime_len/2, ltime_len/2 , ltime_interval) 170 | plt.subplot(2,2,2) 171 | plt.plot(ltime, lstrain, 'g') 172 | plt.xlabel('Time (seconds)') 173 | plt.ylabel('L1 Strain') 174 | plt.title('L1 Strain') 175 | 176 | plt.subplot(2, 1, 2) 177 | plt.plot(reftime, ref_H1) 178 | plt.xlabel('Time (seconds)') 179 | plt.ylabel('Template Strain') 180 | plt.title('Template') 181 | plt.tight_layout() 182 | ``` 183 | -------------------------------------------------------------------------------- /docs/code/13-advanced-vis.txt: -------------------------------------------------------------------------------- 1 | ```bash 2 | # 安装方法 1 3 | conda install seaborn 4 | # 安装方法 2 5 | pip install seaborn 6 | ``` 7 | ```python 8 | import seaborn as sns 9 | ``` 10 | ```python 11 | In [1]: import pandas as pd 12 | ...: import numpy as np 13 | ...: 14 | ...: mtcars = pd.read_csv('files/chapter10/mtcars.csv') 15 | ``` 16 | ```python 17 | In [2]: mtcars.info() 18 | 19 | RangeIndex: 32 entries, 0 to 31 20 | Data columns (total 11 columns): 21 | mpg 32 non-null float64 22 | cyl 32 non-null int64 23 | disp 32 non-null float64 24 | hp 32 non-null int64drat 32 non-null float64 25 | wt 32 non-null float64 26 | qsec 32 non-null float64 27 | vs 32 non-null int64 28 | am 32 non-null int64 29 | gear 32 non-null int64 30 | carb 32 non-null int64 31 | dtypes: float64(5), int64(6) 32 | memory usage: 2.9 KB 33 | ``` 34 | ```python 35 | In [3]: mtcars.describe() 36 | Out[3]: 37 | mpg cyl disp ... am gear carb 38 | count 32.000000 32.000000 32.000000 ... 32.000000 32.000000 32.0000 39 | mean 20.090625 6.187500 230.721875 ... 0.406250 3.687500 2.8125 40 | std 6.026948 1.785922 123.938694 ... 0.498991 0.737804 1.6152 41 | min 10.400000 4.000000 71.100000 ... 0.000000 3.000000 1.0000 42 | 25% 15.425000 4.000000 120.825000 ... 0.000000 3.000000 2.0000 43 | 50% 19.200000 6.000000 196.300000 ... 0.000000 4.000000 2.0000 44 | 75% 22.800000 8.000000 326.000000 ... 1.000000 4.000000 4.0000 45 | max 33.900000 8.000000 472.000000 ... 1.000000 5.000000 8.0000 46 | 47 | [8 rows x 11 columns] 48 | ``` 49 | ```python 50 | In [4]: import seaborn as sns 51 | In [5]: # 注意在 Jupyter Notebook 中使用 %matplotlib inline 52 | ...: %matplotlib 53 | Using matplotlib backend: agg 54 | ``` 55 | ```python 56 | In [6]: sns.pairplot(mtcars.iloc[:, 2:7]) 57 | ``` 58 | ```python 59 | In [7]: sns.pairplot(mtcars.loc[:, ['wt', 'mpg']]) 60 | ``` 61 | ```python 62 | In [8]: sns.pairplot(mtcars.loc[:, ['wt', 'mpg', 'cyl']], hue='cyl') 63 | ``` 64 | ```python 65 | In [9]: sns.set_style('dark') 66 | In [10]: sns.pairplot(mtcars.loc[:, ['wt', 'mpg', 'cyl']], hue='cyl') 67 | ``` 68 | ```python 69 | In [11]: sns.set_style('dark') 70 | In [12]: sns.set_palette('colorblind') 71 | In [13]: sns.pairplot(mtcars.loc[:, ['wt', 'mpg', 'cyl']], 72 | ...: hue='cyl') 73 | ``` 74 | ```python 75 | In [14]: sns.set_style('whitegrid') 76 | In [15]: sns.pairplot(mtcars, 77 | ...: hue='cyl', 78 | ...: vars=['wt', 'mpg', 'cyl']) 79 | ``` 80 | ```python 81 | In [16]: sns.set_style('white') 82 | In [17]: sns.pairplot(mtcars, 83 | ...: hue='cyl', 84 | ...: x_vars=['wt', 'mpg'], 85 | ...: y_vars=['hp', 'disp']) 86 | ``` 87 | ```python 88 | In [18]: sns.set_style('ticks') 89 | In [19]: sns.set_palette('dark') 90 | In [20]: sns.pairplot(mtcars, 91 | ...: kind='reg', 92 | ...: x_vars=['wt', 'mpg'], 93 | ...: y_vars=['hp', 'disp']) 94 | ``` 95 | ```python 96 | In [21]: sns.set_palette('bright') 97 | In [22]: sns.pairplot(mtcars.loc[:, ['wt', 'mpg', 'hp']], 98 | ...: kind='reg', diag_kind='kde') 99 | ``` 100 | ```python 101 | In [23]: sns.barplot(x='cyl', y='mpg', data=mtcars) 102 | ``` 103 | ```python 104 | In [24]: sns.barplot(x='cyl', y='mpg', hue='vs', 105 | ...: data=mtcars) 106 | ``` 107 | ```python 108 | In [25]: sns.countplot(x='cyl', data=mtcars) 109 | ``` 110 | ```python 111 | In [26]: sns.pointplot(x='cyl', 112 | ...: y='wt', 113 | ...: hue='vs', 114 | ...: markers=['^', 'o'], 115 | ...: linestyles=['-', '--'], 116 | ...: data=mtcars) 117 | ``` 118 | ```python 119 | In [27]: sns.boxplot(x='cyl', 120 | ...: y='wt', 121 | ...: hue='vs', 122 | ...: data=mtcars) 123 | ``` 124 | ```python 125 | In [28]: sns.violinplot(x='cyl', 126 | ...: y='wt', 127 | ...: hue='vs', 128 | ...: data=mtcars) 129 | ``` 130 | ```python 131 | In [29]: sns.jointplot(x='mpg', y='wt', 132 | ...: data=mtcars, 133 | ...: kind='kde') 134 | ``` 135 | ```python 136 | In [30]: sns.jointplot(x='mpg', y='wt', 137 | ...: data=mtcars, 138 | ...: kind='reg') 139 | ``` 140 | ```bash 141 | # 安装方法 1 142 | conda install -c conda-forge plotnine 143 | # 安装方法 2 144 | pip install plotnine 145 | ``` 146 | ```python 147 | In [31]: from plotnine import * 148 | In [32]: from plotnine.data import mtcars 149 | In [33]: (ggplot(mtcars, aes('wt', 'mpg', color='factor(gear)')) 150 | ...: + geom_point() 151 | ...: + stat_smooth(method='lm') 152 | ...: + facet_wrap('~gear')) 153 | ``` 154 | ```python 155 | In [34]: mtcars.head() 156 | Out[34]: 157 | mpg cyl disp hp drat wt qsec vs am gear carb 158 | 0 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4 159 | 1 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4 160 | 2 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1 161 | 3 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1 162 | 4 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2 163 | ``` 164 | ```python 165 | In [35]: (ggplot(mtcars, aes(x='wt', y='mpg')) 166 | ...: + geom_point()) 167 | ``` 168 | ```python 169 | In [36]: ggplot(mtcars, aes(x='wt', y='mpg')) 170 | ``` 171 | ```python 172 | In [37]: ggplot(mtcars, aes(x='wt', y='mpg')) + geom_point() 173 | ``` 174 | ```python 175 | In [38]: ggplot(mtcars, aes(x='wt', y='mpg')) + geom_line() 176 | ``` 177 | ```python 178 | In [39]: (ggplot(mtcars, aes(x='wt', y='mpg')) 179 | ...: + geom_smooth(method="lm")) 180 | ``` 181 | ```python 182 | In [40]: (ggplot(mtcars, aes(x='wt', y='mpg')) 183 | ...: + geom_smooth(method="lm") 184 | ...: + geom_point()) 185 | ``` 186 | ```python 187 | In [41]: (ggplot(mtcars, aes(x='wt', y='mpg')) 188 | ...: + geom_smooth(method="lm", color='red') 189 | ...: + geom_point(color='blue')) 190 | ``` 191 | ```python 192 | In [42]: (ggplot(mtcars, aes(x='wt', y='mpg')) 193 | ...: + geom_smooth(method="lm", color="red") 194 | ...: + geom_point(color="blue") 195 | ...: + labs(title="Automobie Data", x="Weight", y="Miles Per Gallon")) 196 | ``` 197 | ```python 198 | In [43]: (ggplot(mtcars, aes(x='hp', y='mpg', 199 | ...: shape='factor(cyl)', color='factor(cyl)')) + 200 | ...: geom_point(size=3) + 201 | ...: facet_grid('am~vs') + 202 | ...: labs(title="Automobile Data by Engine Type", 203 | ...: x="Horsepower", y="Miles Per Gallon")) 204 | ``` 205 | ```python 206 | In [44]: (ggplot(mtcars, aes(x='hp', y='mpg', 207 | ...: shape='factor(cyl)', color='cyl')) + 208 | ...: geom_point(size=3) + 209 | ...: facet_grid('am~vs') + 210 | ...: labs(title="Automobile Data by Engine Type", 211 | ...: x="Horsepower", y="Miles Per Gallon")) 212 | ``` 213 | ```python 214 | In [45]: (ggplot(mtcars, aes(x='factor(cyl)', y='mpg')) 215 | ...: + geom_boxplot(fill='cornflowerblue', color='black', notch=True) 216 | ...: + geom_point(position='jitter', color='blue', alpha=0.5) 217 | ...: + geom_rug(sides='l', color='black')) 218 | ``` 219 | ```bash 220 | # 安装方法 1 221 | conda install bokeh 222 | # 安装方法 2 223 | pip install bokeh 224 | ``` 225 | ```python 226 | In [46]: from bokeh.io import output_notebook, show 227 | In [47]: from bokeh.plotting import figure 228 | ``` 229 | ```python 230 | In [48]: output_notebook() 231 | Loading BokehJS ... 232 | ``` 233 | ```python 234 | In [49]: # 步骤1:使用 figure() 创建图形对象 235 | ...: # 并指定图形的宽高 236 | ...: p = figure(plot_width=400, plot_height=400) 237 | ...: # 步骤2:添加图形元素 238 | ...: # 这里绘制点并指定点的一些属性 239 | ...: # 包括大小、颜色和透明度 240 | ...: p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], 241 | ...: size=15, line_color="navy", 242 | ...: fill_color="orange", fill_alpha=0.5) 243 | ...: # 步骤3:展示图形 244 | ...: show(p) 245 | ``` 246 | ```python 247 | In [50]: p = figure(plot_width=400, plot_height=400) 248 | ...: p.square([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], 249 | ...: size=15, color="firebrick", fill_alpha=0.5) 250 | ...: show(p) 251 | ``` 252 | ```python 253 | In [51]: p = figure(plot_width=400, plot_height=400) 254 | ...: p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], 255 | ...: line_width=2) 256 | ...: show(p) 257 | ``` 258 | ```python 259 | In [52]: # 构建数据 260 | ...: x = [1, 2, 3, 4, 5] 261 | ...: y = [6, 7, 8, 7, 3] 262 | ...: # 步骤1: 263 | ...: p = figure(plot_width=400, plot_height=400) 264 | ...: # 步骤2: 265 | ...: p.line(x, y, line_width=2) 266 | ...: p.circle(x, y, fill_color="white", size=8) 267 | ...: # 步骤3: 268 | ...: show(p) 269 | ``` 270 | ```python 271 | In [53]: # 构建数据 272 | ...: x = [1, 2, 3, 4, 5] 273 | ...: y = [6, 7, 8, 7, 3] 274 | ...: # 绘制图形 1 275 | ...: p1 = figure(plot_width=150, plot_height=150) 276 | ...: p1.circle(x, y, 277 | ...: size=5, line_color="navy", 278 | ...: fill_color="orange", fill_alpha=0.5) 279 | ...: # 绘制图形 2 280 | ...: p2 = figure(plot_width=150, plot_height=150) 281 | ...: p2.square(x, y, 282 | ...: size=5, color="firebrick", fill_alpha=0.5) 283 | ...: # 绘制图形 3 284 | ...: p3 = figure(plot_width=150, plot_height=150) 285 | ...: p3.line(x, y, line_width=2) 286 | ``` 287 | ```python 288 | In [54]: from bokeh.layouts import row, column 289 | ...: # 水平排列 290 | ...: show(row(p1, p2, p3)) 291 | ``` 292 | ```python 293 | In [55]: # 垂直排列 294 | ...: show(column(p1, p2, p3)) 295 | ``` 296 | ```python 297 | In [56]: from bokeh.layouts import gridplot 298 | ...: p = gridplot([[p1, p2], [p3, None]], toolbar_location=None) 299 | ...: show(p) 300 | ``` 301 | -------------------------------------------------------------------------------- /docs/code/14-stats.txt: -------------------------------------------------------------------------------- 1 | ```python 2 | In [1]: import statistics as st # 标准库 3 | ...: import numpy as np 4 | ...: import pandas as pd 5 | ...: mtcars = pd.read_csv('files/chapter10/mtcars.csv') 6 | ``` 7 | ```python 8 | In [2]: st.mean([1, 2, 3]) # 标准库计算 9 | Out[2]: 2 10 | In [3]: np.mean([1, 2, 3]) # NumPy 库计算Out[3]: 2.0 11 | In [4]: pd.Series([1, 2, 3]).mean() # Pandas 库计算 12 | Out[4]: 2.0 13 | ``` 14 | ```python 15 | In [5]: def geo_mean(iterable): 16 | ...: a = np.log(iterable) 17 | ...: return np.exp(a.sum()/len(a)) 18 | In [6]: geo_mean([1, 2, 3]) 19 | Out[6]: 1.8171205928321397 20 | ``` 21 | ```bash 22 | # 安装方法 1 23 | conda install scipy 24 | # 安装方法 2 25 | pip install scipy 26 | ``` 27 | ```python 28 | In [7]: from scipy.stats.mstats import gmean 29 | ...: gmean([1, 2, 3]) 30 | Out[7]: 1.8171205928321397 31 | ``` 32 | ```python 33 | In [8]: st.median([1, 2, 1000]) 34 | Out[8]: 2 35 | In [9]: np.median([1, 2, 1000]) 36 | Out[9]: 2.0 37 | ``` 38 | ```python 39 | In [10]: pd.Series([1, 2, 3, 1000]).median() 40 | Out[10]: 2.5 41 | ``` 42 | ```python 43 | In [11]: pd.Series([1, 2, 2, 3, 3, 5]).mode() 44 | Out[11]: 45 | 0 2 46 | 1 3 47 | dtype: int64 48 | ``` 49 | ```python 50 | In [12]: a = [1, 2, 3, 1000] ...: max(a) - min(a) 51 | Out[12]: 999 52 | ``` 53 | ```python 54 | In [13]: pd.Series([1, 2, 3, 1]).var() 55 | Out[13]: 0.9166666666666666 56 | In [14]: pd.Series([1, 2, 3, 1000]).var() 57 | Out[14]: 249001.66666666666 58 | ``` 59 | ```python 60 | In [15]: pd.Series([1, 2, 3, 1]).std() 61 | Out[15]: 0.9574271077563381 62 | ``` 63 | ```python 64 | In [16]: mtcars.describe() 65 | Out[16]: 66 | mpg cyl disp ... am gear carb 67 | count 32.000000 32.000000 32.000000 ... 32.000000 32.000000 32.0000 68 | mean 20.090625 6.187500 230.721875 ... 0.406250 3.687500 2.8125 69 | std 6.026948 1.785922 123.938694 ... 0.498991 0.737804 1.6152 70 | min 10.400000 4.000000 71.100000 ... 0.000000 3.000000 1.0000 71 | 25% 15.425000 4.000000 120.825000 ... 0.000000 3.000000 2.0000 72 | 50% 19.200000 6.000000 196.300000 ... 0.000000 4.000000 2.0000 73 | 75% 22.800000 8.000000 326.000000 ... 1.000000 4.000000 4.0000 74 | max 33.900000 8.000000 472.000000 ... 1.000000 5.000000 8.0000 75 | 76 | [8 rows x 11 columns] 77 | ``` 78 | ```python 79 | In [17]: mtcars.wt.skew() 80 | Out[17]: 0.4659161067929868 81 | ``` 82 | ```python 83 | In [18]: %matplotlib # Notebook 使用 %matplotlib inline 84 | ...: mtcars.wt.plot(kind='kde') 85 | ``` 86 | ```python 87 | In [19]: mtcars.wt.kurtosis() 88 | Out[19]: 0.41659466963492564 89 | ``` 90 | ```python 91 | In [20]: mtcars.cyl.kurtosis() 92 | Out[20]: -1.7627938970111958 93 | In [21]: mtcars.cyl.plot(kind='kde') 94 | ``` 95 | ```python 96 | In [22]: from scipy import stats 97 | ...: import matplotlib.pyplot as plt 98 | ...: mu = 0 # 均值 99 | ...: sigma = 1 # 标准差 100 | ...: x = np.arange(-5,5,0.1) 101 | ...: y = stats.norm.pdf(x,mu,sigma) # 生成正态分布概率函数值 102 | ...: plt.plot(x, y) 103 | ...: plt.title('Normal: $\mu$=%.1f, $\sigma^2$=%.1f' % (mu,sigma)) 104 | ...: plt.xlabel('x') 105 | ...: plt.ylabel('Probability density', fontsize=15) 106 | ...: plt.show() 107 | ``` 108 | ```python 109 | In [23]: # 使用rvs()函数模拟一个二项随机变量 110 | ...: data = stats.binom.rvs(n=10,p=0.5,size=10) 111 | ...: 112 | ...: plt.hist(data, density=True) 113 | ...: plt.xlabel('x') 114 | ...: plt.ylabel('Probability density', fontsize=15) 115 | ...: plt.title('Binormal: n=10,$p$=0.5') 116 | ...: plt.show() 117 | ``` 118 | ```python 119 | In [24]: data = stats.binom.rvs(n=10,p=0.5,size=1000) 120 | ...: plt.hist(data, density=True) 121 | ...: plt.xlabel('x') 122 | ...: plt.ylabel('Probability density', fontsize=15) 123 | ...: plt.title('Binormal: n=10,$p$=0.5') 124 | ...: plt.show() 125 | ``` 126 | ```python 127 | In [25]: data = stats.bernoulli.rvs(p=0.6, size=10) 128 | ...: plt.hist(data) 129 | ...: plt.xlabel('x') 130 | ...: plt.ylabel('Frequency', fontsize=15) 131 | ...: plt.title('Bernouli: $p$=0.5') 132 | ...: plt.show() 133 | ``` 134 | ```python 135 | In [26]: data = stats.expon.rvs(scale=2,size=1000) # scale参数表示λ的倒数 136 | ...: plt.hist(data, density=True, bins=20) 137 | ...: plt.xlabel('x') 138 | ...: plt.ylabel('Probability density', fontsize=15) 139 | ...: plt.title('Exponential: 1/$\lambda$=2') 140 | ...: plt.show() 141 | ``` 142 | ```python 143 | In [27]: data = stats.poisson.rvs(mu=2,size=1000) # scale参数表示λ的倒数 144 | ...: plt.hist(data, density=True, bins=20) 145 | ...: plt.xlabel('x') 146 | ...: plt.ylabel('Probability density', fontsize=15) 147 | ...: plt.title('Poisson: $\lambda$=2') 148 | ...: plt.show() 149 | ``` 150 | ```python 151 | In [28]: from scipy import stats 152 | ...: height = [1.75, 1.58, 1.71, 1.64, 1.55, 1.72, 1.62, 1.83, 1.63, 1.65] 153 | ...: print(stats.ttest_1samp(height, 1.60)) 154 | Ttest_1sampResult(statistic=2.550797248729806, pvalue=0.03115396848888224) 155 | ``` 156 | ```python 157 | In [29]: quality_A = stats.norm.rvs(loc = 9,scale = 10,size = 500) 158 | ...: quality_B = stats.norm.rvs(loc = 7,scale = 10,size = 500) 159 | ...: 160 | ...: _ = plt.hist(quality_A, density=True, alpha=0.5) 161 | ...: _ = plt.hist(quality_B, density=True, color="red", alpha=0.5) 162 | ``` 163 | -------------------------------------------------------------------------------- /docs/code/15-append.txt: -------------------------------------------------------------------------------- 1 | ```python 2 | %paste # 粘贴代码 3 | %run # 执行外部脚本 4 | %timeit # 计算代码运行时间 5 | %magic # 获取可用魔术命令描述与示例 6 | %lsmagic # 获取可用魔术命令列表 7 | %ls # 列出当前目录列表 8 | %pwd # 获取当前所在(工作)目录 9 | %cd # 切换工作目录 10 | %mkdir # 创建文件夹 11 | %cp # 拷贝文件 12 | %rm # 删除文件 13 | ``` 14 | ```python 15 | In [4]: %lsmagic 16 | Out[4]: 17 | Available line magics: 18 | %alias %alias_magic %autoawait %autocall %autoindent %automagic %bookmark %cat %cd %clear %colors %conda %config %cp %cpaste %debug %dhist %dirs %doctest_mode %ed %edit %env %gui %hist %history %killbgscripts %ldir %less %lf %lk %ll %load %load_ext %loadpy %logoff %logon %logstart %logstate %logstop %ls %lsmagic %lx %macro %magic %m 19 | an %matplotlib %mkdir %more %mv %notebook %page %paste %pastebin %pdb %pdef %pdoc %pfile %pinfo %pinfo2 %pip %popd %pprint %precision %prun %psearch %psource %pushd % 20 | pwd %pycat %pylab %quickref %recall %rehashx %reload_ext %rep %rerun %reset %reset_selective %rm %rmdir %run %save %sc %set_env %store %sx %system %tb %time %timeit % 21 | unalias %unload_ext %who %who_ls %whos %xdel %xmode 22 | 23 | Available cell magics: 24 | %%! %%HTML %%SVG %%bash %%capture %%debug %%file %%html %%javascript %%js %%latex %%markdown %%perl %%prun %%pypy %%python %%python2 %%python3 %%ruby %%script %%sh %%sv 25 | g %%sx %%system %%time %%timeit %%writefile 26 | 27 | Automagic is ON, % prefix IS NOT needed for line magics. 28 | ``` 29 | ```python 30 | In [5]: %ls? 31 | Repr: 32 | ``` 33 | ```python 34 | In [6]: %ls 35 | 36 | ``` 37 | ```python 38 | In [7]: %mkdir new 39 | In [8]: %ls 40 | new/ 41 | ``` 42 | ```python 43 | In [9]: %pwd 44 | Out[9]: '/home/shixiang/Proj/pybook/test_ipython_shell' 45 | ``` 46 | ```python 47 | In [10]: %cd new 48 | /home/shixiang/Proj/pybook/test_ipython_shell/new 49 | In [11]: %pwd 50 | Out[11]: '/home/shixiang/Proj/pybook/test_ipython_shell/new' 51 | ``` 52 | ```python 53 | In [12]: %timeit Result = [i ** 2 for i in range(100)] 54 | 47.6 µs ± 386 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each) 55 | ``` 56 | ```python 57 | In [13]: %%timeit 58 | ...: Result = [] 59 | ...: for i in range(100): 60 | ...: Result.append(i * i) 61 | ...: 62 | 16.7 µs ± 178 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each) 63 | ``` 64 | ```python 65 | In [1]: class Student: 66 | ...: def __init__(self, name, age, height, score): 67 | ...: self.name = name 68 | ...: self.age = age 69 | ...: self.height = height 70 | ...: self.score = score 71 | ``` 72 | ```python 73 | In [2]: Student('小周', 20, 180, 98) 74 | Out[2]: <__main__.Student at 0x7fe95c4eeb50> 75 | ``` 76 | ```python 77 | In [3]: zhou = Student('小周', 20, 180, 98) 78 | In [4]: zhou.score 79 | Out[4]: 98 80 | In [5]: zhou.height 81 | Out[5]: 180 82 | In [6]: zhou.age 83 | Out[6]: 20 84 | ``` 85 | ```python 86 | In [7]: class Student: 87 | ...: def __init__(self, name, age, height, score): 88 | ...: self.name = name 89 | ...: self.age = age 90 | ...: self.height = height 91 | ...: self.score = score 92 | ...: def diff(self, average_score): 93 | ...: print(self.score - average_score) 94 | ...: 95 | ``` 96 | ```python 97 | zhou = Student('小周', 20, 180, 98) 98 | ``` 99 | ```python 100 | In [9]: zhou.diff(70) 101 | 28 102 | ``` 103 | ```python 104 | In [15]: class Student2(Student): 105 | ...: def __init__(self, name, age, height, score, class_name, teacher_name): 106 | ...: Student.__init__(self, name, age, height, score) 107 | ...: self.class_name = class_name 108 | ...: self.teacher_name = teacher_name 109 | ...: 110 | ``` 111 | ```python 112 | In [16]: zhou = Student2('小周', 20, 180, 98, "Class A", "Mr. Zhang") 113 | ``` 114 | ```python 115 | In [17]: zhou.name 116 | Out[17]: '小周' 117 | In [18]: zhou.diff(70) 118 | 28 119 | ``` 120 | -------------------------------------------------------------------------------- /docs/code/README.txt: -------------------------------------------------------------------------------- 1 | copyright@2020 Shixiang Wang 2 | 3 | === 4 | 5 | 本目录存储书籍所涉及的所有程序块(终端命令)。 6 | 7 | 推荐使用 Typora(https://typora.io/)打开阅读。 -------------------------------------------------------------------------------- /docs/code_py/02-base.py: -------------------------------------------------------------------------------- 1 | print('你好啊,世界!) 2 | # print('你好啊,世界')! # 错误写法 3 | 3 + 2 # 加法 4 | 3 / 2 # 浮点数除法 5 | 3 // 2 # 整除 6 | 3 * 2 # 乘法 7 | 3 ** 2 # 指数(幂) 8 | 3 % 2 # 求余 9 | abs(a) # 绝对值 10 | 1 + 1 11 | # Out[3]: 2 12 | 13 | 1 - 1 14 | # Out[4]: 0 15 | 16 | 1 * 1 17 | # Out[5]: 1 18 | 19 | 1 / 1 20 | # Out[6]: 1.0 21 | 70 / 1.82 ** 2 22 | # Out[11]: 21.132713440405748 23 | 70 / 1.82 ** 2 # 计算我的 BMI 24 | # Out[12]: 21.132713440405748 25 | # 计算我的 BMI 26 | 70 / 1.82 ** 2 27 | # Out[14]: 21.132713440405748 28 | # 计算我的 BMI 70 / 1.82 ** 2 29 | 计算我的 BMI 指数 70 / 1.82 ** 2 30 | # File "", line 1 31 | # 计算我的 BMI 指数 70 / 1.82 ** 2 32 | # ^ 33 | # SyntaxError: invalid syntax 34 | # 与朋友比较 BMI 指数 35 | 70 / 1.82 ** 2 36 | # Out[10]: 21.132713440405748 37 | 38 | 48 / 1.64 ** 2 39 | # Out[11]: 17.846519928613922 40 | 41 | 70 / 1.82 ** 2 - 48 / 1.64 ** 2 42 | # Out[12]: 3.2861935117918257 43 | height = 1.82 44 | 45 | weight = 70 46 | print(height) 47 | # Out[15]: 1.82 48 | 49 | print(weight) 50 | # Out[16]: 70 51 | 52 | height 53 | # Out[17]: 1.82 54 | 55 | weight 56 | # Out[18]: 70 57 | myBMI = 70 / 1.82 ** 2 # 我的 BMI 58 | friendBMI = 48 / 1.64 ** 2 # 朋友的 BMI 59 | myBMI - friendBMI # 我与朋友的 BMI 值的差异 60 | # Out[21]: 3.2861935117918257 61 | __myName = "ShixiangWang" 62 | 63 | my-name = "ShixiangWang" # 错误的表示方法 64 | 'What's your name?' # 错误的表示方法 65 | # File "", line 1 66 | # 'What's your name?' # 错误的表示方法 67 | # ^ 68 | # SyntaxError: invalid syntax 69 | 70 | 'What\'s your name?' # 使用转义\对字符串中的英文单引号进行转义 71 | # Out[27]: "What's your name?" 72 | "What\'s your name?" # 将英文单引号嵌入英文双引号中 73 | # Out[28]: "What's your name?" 74 | "This is the first sentence.\ 75 | This is the second sentence." 76 | "Newlines are indicated by \n" 77 | # Out[35]: 'Newlines are indicated by \n' 78 | 79 | r"Newlines are indicated by \n" 80 | # Out[36]: 'Newlines are indicated by \\n' 81 | 82 | print(r"Newlines are indicated by \n") 83 | # Out[37]: Newlines are indicated by \n 84 | 85 | print("Newlines are indicated by \n") 86 | # Out[38]: Newlines are indicated by 87 | # 此处输出一个空行 88 | type1 = 1 89 | type2 = 1.0 90 | type3 = "1" 91 | type4 = True 92 | type(type1) 93 | # Out[49]: int 94 | type(type2) 95 | # Out[50]: float 96 | type(type3) 97 | # Out[51]: str 98 | type(type4) 99 | # Out[52]: bool 100 | '1' + '1' 101 | # Out[2]: '11' 102 | '1' - '1' 103 | # --------------------------------------------------------------------------- 104 | # TypeError Traceback (most recent call last) 105 | # in () 106 | # ----> 1 '1' - '1' 107 | 108 | # TypeError: unsupported operand type(s) for -: 'str' and 'str' 109 | type('1') 110 | # Out[8]: str 111 | 112 | type(int('1')) 113 | # Out[9]: int 114 | "我的语文和数学成绩之和是 " + 199 115 | # --------------------------------------------------------------------------- 116 | # TypeError Traceback (most recent call last) 117 | # in () 118 | # ----> 1 "我的语文和数学成绩之和是 " + 199 119 | 120 | # TypeError: must be str, not int 121 | 122 | "我的语文和数学成绩之和是 " + str(199) 123 | # Out[11]: '我的语文和数学成绩之和是 199' 124 | 9 + 2 # 加 125 | 9 - 2 # 减 126 | 9 * 2 # 乘 127 | 9 / 2 # 除(浮点输出) 128 | 9 //2 # 整除 129 | 9 % 2 # 求余 130 | 9 **2 # 幂 131 | '这是一个' + '字符串' # 字符串连接 132 | '这是一个字符串' * 5 # 字符串重复 133 | 5 == 4 # 等于 134 | 5 > 4 # 大于 135 | 5 < 4 # 小于 136 | 5 != 4 # 不等于 137 | 5 >= 4 # 大于或等于 138 | 5 <= 4 # 小于或等于 139 | True and True # 逻辑“与” 140 | True or False # 逻辑“或” 141 | not False # 逻辑“非” 142 | -------------------------------------------------------------------------------- /docs/code_py/03-data-structure.py: -------------------------------------------------------------------------------- 1 | vowels = ['a', 'e', 'i', 'o', 'u'] 2 | vowels 3 | # Out[2]: ['a', 'e', 'i', 'o', 'u'] 4 | array_init = [] 5 | array_init 6 | # Out[4]: [] 7 | vowels[2] 8 | # Out[5]: 'i' 9 | rectangle = ['长方形1', 20, [4, 5], '长方形2', 16, [4, 4]] 10 | rectangle 11 | # Out[8]: ['长方形1', 20, [4, 5], '长方形2', 16, [4, 4]] 12 | len(rectangle) 13 | # Out[9]: 6 14 | rectangle[6] 15 | # --------------------------------------------------------------------------- 16 | # IndexError Traceback (most recent call last) 17 | # in () 18 | # ----> 1 rectangle[6] 19 | 20 | # IndexError: list index out of range 21 | aseq = "atggctaggc" 22 | list(aseq) 23 | # Out[18]: ['a', 't', 'g', 'g', 'c', 't', 'a', 'g', 'g', 'c'] 24 | odd_numbers = [1, 3, 5, 7, 8] 25 | odd_numbers = [1, 3, 5, 7, 9] 26 | odd_numbers = [1, 3, 5, 7, 8] 27 | odd_numbers[4] = 9 28 | odd_numbers 29 | # Out[15]: [1, 3, 5, 7, 9] 30 | odd_numbers[-1] 31 | # Out[16]: 9 32 | print(odd_numbers[0]) 33 | print(odd_numbers[1]) 34 | print(odd_numbers[2]) 35 | print(odd_numbers[3]) 36 | print(odd_numbers[4]) 37 | for i in odd_numbers: 38 | print(i) 39 | 40 | # 1 41 | # 3 42 | # 5 43 | # 7 44 | # 9 45 | nested_list = ['记录', 3, ['小明', '小红', '小蓝'], [2.30, 2.41, 2.33]] 46 | for i in nested_list: 47 | print(i) 48 | # 记录 49 | # 3 50 | # ['小明', '小红', '小蓝'] 51 | # [2.3, 2.41, 2.33] 52 | a * 5 53 | # Out[33]: [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3] 54 | letters7 = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] 55 | you_want = letters7[0:4] 56 | you_want 57 | # Out[38]: ['a', 'b', 'c', 'd'] 58 | letters7[0:4:1] 59 | # Out[39]: ['a', 'b', 'c', 'd'] 60 | letters7[:4] 61 | # Out[40]: ['a', 'b', 'c', 'd'] 62 | letters7[:7] 63 | # Out[41]: ['a', 'b', 'c', 'd', 'e', 'f', 'g'] 64 | letters7[4:] 65 | # Out[42]: ['e', 'f', 'g'] 66 | letters7[-1] 67 | # Out[43]: 'g' 68 | letters7[-1:] 69 | # Out[44]: ['g'] 70 | letters7[::1] 71 | # Out[45]: ['a', 'b', 'c', 'd', 'e', 'f', 'g'] 72 | letters7[::2] 73 | # Out[46]: ['a', 'c', 'e', 'g'] 74 | letters7[::-1] 75 | # Out[47]: ['g', 'f', 'e', 'd', 'c', 'b', 'a'] 76 | letters7[::-2] 77 | # Out[48]: ['g', 'e', 'c', 'a'] 78 | letters7[0:2] = ['h', 'i'] 79 | letters7 80 | # Out[50]: ['h', 'i', 'c', 'd', 'e', 'f', 'g'] 81 | letters7[0:2] = ['a'] 82 | letters7 83 | # Out[52]: ['a', 'c', 'd', 'e', 'f', 'g'] 84 | letters7[0:1] = ['a', 'b'] 85 | letters7 86 | # Out[54]: ['a', 'b', 'c', 'd', 'e', 'f', 'g'] 87 | letters7[0:2] = 'h' 88 | letters7 89 | # Out[56]: ['h', 'c', 'd', 'e', 'f', 'g'] 90 | example_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 91 | example_list.append(11) 92 | example_list 93 | # Out[61]: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] 94 | 95 | example_list.insert(2, 12) 96 | example_list 97 | # Out[63]: [1, 2, 12, 3, 4, 5, 6, 7, 8, 9, 10, 11] 98 | example_list.extend([13,14]) 99 | example_list 100 | # Out[65]: [1, 2, 12, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14] 101 | example_list.pop() 102 | # Out[67]: 14 103 | example_list.pop(2) 104 | # Out[68]: 12 105 | example_list.remove(13) 106 | example_list 107 | # Out[70]: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] 108 | del example_list[10] 109 | example_list 110 | # Out[72]: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 111 | example_list.clear() 112 | example_list 113 | # Out[74]: [] 114 | a = [3, 1, 2, 5, 4, 6] 115 | a.sort() 116 | a 117 | # Out[80]: [1, 2, 3, 4, 5, 6] 118 | nums = [-1, 34, 0.2, -4, 309] 119 | nums_desc = sorted(nums, reverse=True) 120 | nums 121 | # Out[83]: [-1, 34, 0.2, -4, 309] 122 | nums_desc 123 | # Out[84]: [309, 34, 0.2, -1, -4] 124 | nums 125 | # Out[90]: [1, 2, 2, 2, 3, 3, 4, 5] 126 | nums.reverse() 127 | nums 128 | # Out[92]: [5, 4, 3, 3, 2, 2, 2, 1] 129 | min(nums) 130 | # Out[85]: -4 131 | max(nums) 132 | # Out[86]: 309 133 | nums = [1, 2, 2, 2, 3, 3, 4, 5] 134 | nums.count(2) 135 | # Out[88]: 3 136 | nums.count(3) 137 | # Out[89]: 2 138 | sum(nums) 139 | # Out[93]: 22 140 | 4 in example_list 141 | # Out[76]: False 142 | 3 in example_list 143 | # Out[77]: True 144 | conditions = [True, False, True] 145 | all(conditions) 146 | # Out[95]: False 147 | any(conditions) 148 | # Out[96]: True 149 | a = [1, 2, 3, 4] 150 | 151 | a == [1, 2, 3, 5] 152 | # Out[98]: False 153 | a == [1, 3, 2, 4] 154 | # Out[99]: False 155 | a == [1, 2, 3, 4] 156 | # Out[100]: True 157 | s = 'interactive Python' 158 | t = list(s) 159 | t 160 | # Out[103]: 161 | ['i', 162 | 'n', 163 | 't', 164 | 'e', 165 | 'r', 166 | 'a', 167 | 'c', 168 | 't', 169 | 'i', 170 | 'v', 171 | 'e', 172 | ' ', 173 | 'P', 174 | 'y', 175 | 't', 176 | 'h', 177 | 'o', 178 | 'n'] 179 | s.split() 180 | # Out[104]: ['interactive', 'Python'] 181 | s = 'interactive-Python' 182 | s.split('-') 183 | # Out[107]: ['interactive', 'Python'] 184 | t = ['我','是', '谁', '?'] 185 | ''.join(t) 186 | # Out[109]: '我是谁?' 187 | a = 'banana' 188 | b = 'banana' 189 | a is b 190 | # Out[6]: True 191 | id(a) 192 | # Out[10]: 1691582590008 193 | id(b) 194 | # Out[11]: 1691582590008 195 | a = "orange" 196 | b 197 | # Out[13]: 'banana' 198 | a = [1, 2, 3] 199 | b = [1, 2, 3] 200 | 201 | a is b 202 | # Out[16]: False 203 | 204 | id(a) 205 | # Out[17]: 1691581888264 206 | id(b) 207 | # Out[18]: 1691582794120 208 | b = a 209 | 210 | a is b 211 | # Out[20]: True 212 | 213 | id(b) 214 | # Out[21]: 1691581888264 215 | e = a 216 | 217 | e 218 | # Out[23]: [1, 2, 3] 219 | a 220 | # Out[24]: [1, 2, 3] 221 | 222 | a[1] = 4 223 | e 224 | # Out[26]: [1, 4, 3] 225 | a_tuple = (1, 2, 3) 226 | a_list = [1, 2, 3] 227 | another_tuple = 1,2,3 228 | type(another_tuple) 229 | # Out[7]: tuple 230 | 1 231 | # Out[8]: 1 232 | 233 | (1) 234 | # Out[9]: 1 235 | 236 | 1, 237 | # Out[10]: (1,) 238 | 239 | (1,) 240 | # Out[11]: (1,) 241 | tuple("Python") 242 | # Out[14]: ('P', 'y', 't', 'h', 'o', 'n') 243 | tuple(["I", "am", ["learning", "Python"]]) 244 | # Out[15]: ('I', 'am', ['learning', 'Python']) 245 | ('a',) + ('b',) 246 | # Out[16]: ('a', 'b') 247 | 248 | ('a',) * 3 249 | # Out[17]: ('a', 'a', 'a') 250 | pythonName = tuple("Python") 251 | pythonName 252 | # Out[19]: ('P', 'y', 't', 'h', 'o', 'n') 253 | 254 | pythonName[0] 255 | # Out[20]: 'P' 256 | pythonName[0:3] 257 | # Out[21]: ('P', 'y', 't') 258 | pythonName[3:] 259 | # Out[22]: ('h', 'o', 'n') 260 | pythonName[0] = 'p' 261 | # --------------------------------------------------------------------------- 262 | # TypeError Traceback (most recent call last) 263 | # in () 264 | # ----> 1 pythonName[0] = 'p' 265 | 266 | # TypeError: 'tuple' object does not support item assignment 267 | newName = ('p',) + pythonName[1:] 268 | newName 269 | # Out[25]: ('p', 'y', 't', 'h', 'o', 'n') 270 | weight = {'小红':65, '小明':45, '我':75} 271 | weight 272 | # Out[6]: {'小明': 45, '小红': 65, '我': 75} 273 | weight['小明'] 274 | # Out[7]: 45 275 | weight.keys() 276 | # Out[8]: dict_keys(['小红', '小明', '我']) 277 | weight.values() 278 | # Out[9]: dict_values([65, 45, 75]) 279 | int_dict = {} 280 | int_dict 281 | # Out[11]: {} 282 | rgb = [('red', 'ff0000'), ('green', '00ff00'), ('blue', '0000ff')] 283 | 284 | dict(rgb) 285 | # Out[14]: {'blue': '0000ff', 'green': '00ff00', 'red': 'ff0000'} 286 | dict(red='ff0000',green='00ff00', blue='0000ff') 287 | # Out[15]: {'blue': '0000ff', 'green': '00ff00', 'red': 'ff0000'} 288 | rgb = {} 289 | 290 | rgb['red'] = 'ff0000' 291 | rgb['green'] = '00ff00' 292 | rgb['blue'] = '0000ff' 293 | 294 | rgb 295 | # Out[20]: {'blue': '0000ff', 'green': '00ff00', 'red': 'ff0000'} 296 | len(rgb) 297 | # Out[21]: 3 298 | rgb.pop() 299 | # --------------------------------------------------------------------------- 300 | # TypeError Traceback (most recent call last) 301 | # in () 302 | # ----> 1 rgb.pop() 303 | 304 | # TypeError: pop expected at least 1 arguments, got 0 305 | 306 | rgb.pop('blue') 307 | # Out[23]: '0000ff' 308 | rgb 309 | # Out[24]: {'green': '00ff00', 'red': 'ff0000'} 310 | del rgb 311 | rgb 312 | # --------------------------------------------------------------------------- 313 | # NameError Traceback (most recent call last) 314 | # in () 315 | # ----> 1 rgb 316 | 317 | # NameError: name 'rgb' is not defined 318 | rgb.get('red', '键不存在') 319 | # Out[28]: 'ff0000' 320 | rgb.get('yellow', '键不存在') 321 | # Out[29]: '键不存在' 322 | from collections import OrderedDict 323 | 324 | OrderedDict(rgb) 325 | # Out[33]: OrderedDict([('red', 'ff0000'), ('green', '00ff00'), ('blue', '0000ff')]) 326 | 327 | order_dict = OrderedDict() 328 | order_dict['a'] = 1 329 | order_dict['b'] = 2 330 | order_dict['c'] = 3 331 | order_dict 332 | # Out[39]: OrderedDict([('a', 1), ('b', 2), ('c', 3)]) 333 | a_set = {1, 2, 3, 4, 5, 5, 4} 334 | a_set 335 | # Out[41]: {1, 2, 3, 4, 5} 336 | a_set = {} 337 | a_set.add(1) 338 | # --------------------------------------------------------------------------- 339 | # AttributeError Traceback (most recent call last) 340 | # in () 341 | # ----> 1 a_set.add(1) 342 | 343 | # AttributeError: 'dict' object has no attribute 'add' 344 | a_set = set() 345 | a_set.add(1) 346 | a_set 347 | # Out[46]: {1} 348 | a_set = set([1, 2, 3, 4, 5]) 349 | b_set = set([4, 5, 6, 7, 8]) 350 | a_set 351 | # Out[49]: {1, 2, 3, 4, 5} 352 | b_set 353 | # Out[50]: {4, 5, 6, 7, 8} 354 | 355 | a_set.union(b_set) 356 | # Out[51]: {1, 2, 3, 4, 5, 6, 7, 8} 357 | a_set.intersection(b_set) 358 | # Out[52]: {4, 5} 359 | a_set.difference(b_set) 360 | # Out[53]: {1, 2, 3} 361 | fs = frozenset(['a', 'b']) 362 | fs 363 | # Out[2]: frozenset({'a', 'b'}) 364 | 365 | fs.remove('a') 366 | # --------------------------------------------------------------------------- 367 | # AttributeError Traceback (most recent call last) 368 | # in () 369 | # ----> 1 fs.remove('a') 370 | 371 | # AttributeError: 'frozenset' object has no attribute 'remove' 372 | 373 | fs.add('c') 374 | # --------------------------------------------------------------------------- 375 | # AttributeError Traceback (most recent call last) 376 | # in () 377 | # ----> 1 fs.add('c') 378 | 379 | # AttributeError: 'frozenset' object has no attribute 'add' 380 | -------------------------------------------------------------------------------- /docs/code_py/09-markdown.py: -------------------------------------------------------------------------------- 1 | def test(): 2 | print("语法高亮") 3 | import numpy as np 4 | import matplotlib.pyplot as plt 5 | from scipy.io import wavfile 6 | rate_h, hstrain= wavfile.read(r"H1_Strain.wav","rb") 7 | rate_l, lstrain= wavfile.read(r"L1_Strain.wav","rb") 8 | reftime, ref_H1 = np.genfromtxt('wf_template.txt').transpose() 9 | 10 | # 这里我们使用频率的倒数来确定波的周期 11 | htime_interval = 1/rate_h 12 | ltime_interval = 1/rate_l 13 | # 使用 print() 函数对各项输入的数据进行简单的查看 14 | print(rate_h, hstrain) 15 | print(rate_l, lstrain) 16 | print(reftime, ref_H1) 17 | # 设定在 Notebook 中使用绘图 18 | %matplotlib inline 19 | htime_len = hstrain.shape[0]/rate_h 20 | htime = np.arange(-htime_len/2, htime_len/2 , htime_interval) 21 | plt.subplot(2,2,1) 22 | plt.plot(htime, hstrain, 'y') 23 | plt.xlabel('Time (seconds)') 24 | plt.ylabel('H1 Strain') 25 | plt.title('H1 Strain') 26 | 27 | ltime_len = lstrain.shape[0]/rate_l 28 | ltime = np.arange(-ltime_len/2, ltime_len/2 , ltime_interval) 29 | plt.subplot(2,2,2) 30 | plt.plot(ltime, lstrain, 'g') 31 | plt.xlabel('Time (seconds)') 32 | plt.ylabel('L1 Strain') 33 | plt.title('L1 Strain') 34 | 35 | plt.subplot(2, 1, 2) 36 | plt.plot(reftime, ref_H1) 37 | plt.xlabel('Time (seconds)') 38 | plt.ylabel('Template Strain') 39 | plt.title('Template') 40 | plt.tight_layout() 41 | -------------------------------------------------------------------------------- /docs/code_py/13-advanced-vis.py: -------------------------------------------------------------------------------- 1 | import seaborn as sns 2 | In [1]: import pandas as pd 3 | ...: import numpy as np 4 | ...: 5 | ...: mtcars = pd.read_csv('files/chapter10/mtcars.csv') 6 | In [2]: mtcars.info() 7 | 8 | RangeIndex: 32 entries, 0 to 31 9 | Data columns (total 11 columns): 10 | mpg 32 non-null float64 11 | cyl 32 non-null int64 12 | disp 32 non-null float64 13 | hp 32 non-null int64drat 32 non-null float64 14 | wt 32 non-null float64 15 | qsec 32 non-null float64 16 | vs 32 non-null int64 17 | am 32 non-null int64 18 | gear 32 non-null int64 19 | carb 32 non-null int64 20 | dtypes: float64(5), int64(6) 21 | memory usage: 2.9 KB 22 | In [3]: mtcars.describe() 23 | # Out[3]: 24 | mpg cyl disp ... am gear carb 25 | count 32.000000 32.000000 32.000000 ... 32.000000 32.000000 32.0000 26 | mean 20.090625 6.187500 230.721875 ... 0.406250 3.687500 2.8125 27 | std 6.026948 1.785922 123.938694 ... 0.498991 0.737804 1.6152 28 | min 10.400000 4.000000 71.100000 ... 0.000000 3.000000 1.0000 29 | 25% 15.425000 4.000000 120.825000 ... 0.000000 3.000000 2.0000 30 | 50% 19.200000 6.000000 196.300000 ... 0.000000 4.000000 2.0000 31 | 75% 22.800000 8.000000 326.000000 ... 1.000000 4.000000 4.0000 32 | max 33.900000 8.000000 472.000000 ... 1.000000 5.000000 8.0000 33 | 34 | [8 rows x 11 columns] 35 | In [4]: import seaborn as sns 36 | In [5]: # 注意在 Jupyter Notebook 中使用 %matplotlib inline 37 | ...: %matplotlib 38 | Using matplotlib backend: agg 39 | In [6]: sns.pairplot(mtcars.iloc[:, 2:7]) 40 | In [7]: sns.pairplot(mtcars.loc[:, ['wt', 'mpg']]) 41 | In [8]: sns.pairplot(mtcars.loc[:, ['wt', 'mpg', 'cyl']], hue='cyl') 42 | In [9]: sns.set_style('dark') 43 | In [10]: sns.pairplot(mtcars.loc[:, ['wt', 'mpg', 'cyl']], hue='cyl') 44 | In [11]: sns.set_style('dark') 45 | In [12]: sns.set_palette('colorblind') 46 | In [13]: sns.pairplot(mtcars.loc[:, ['wt', 'mpg', 'cyl']], 47 | ...: hue='cyl') 48 | In [14]: sns.set_style('whitegrid') 49 | In [15]: sns.pairplot(mtcars, 50 | ...: hue='cyl', 51 | ...: vars=['wt', 'mpg', 'cyl']) 52 | In [16]: sns.set_style('white') 53 | In [17]: sns.pairplot(mtcars, 54 | ...: hue='cyl', 55 | ...: x_vars=['wt', 'mpg'], 56 | ...: y_vars=['hp', 'disp']) 57 | In [18]: sns.set_style('ticks') 58 | In [19]: sns.set_palette('dark') 59 | In [20]: sns.pairplot(mtcars, 60 | ...: kind='reg', 61 | ...: x_vars=['wt', 'mpg'], 62 | ...: y_vars=['hp', 'disp']) 63 | In [21]: sns.set_palette('bright') 64 | In [22]: sns.pairplot(mtcars.loc[:, ['wt', 'mpg', 'hp']], 65 | ...: kind='reg', diag_kind='kde') 66 | In [23]: sns.barplot(x='cyl', y='mpg', data=mtcars) 67 | In [24]: sns.barplot(x='cyl', y='mpg', hue='vs', 68 | ...: data=mtcars) 69 | In [25]: sns.countplot(x='cyl', data=mtcars) 70 | In [26]: sns.pointplot(x='cyl', 71 | ...: y='wt', 72 | ...: hue='vs', 73 | ...: markers=['^', 'o'], 74 | ...: linestyles=['-', '--'], 75 | ...: data=mtcars) 76 | In [27]: sns.boxplot(x='cyl', 77 | ...: y='wt', 78 | ...: hue='vs', 79 | ...: data=mtcars) 80 | In [28]: sns.violinplot(x='cyl', 81 | ...: y='wt', 82 | ...: hue='vs', 83 | ...: data=mtcars) 84 | In [29]: sns.jointplot(x='mpg', y='wt', 85 | ...: data=mtcars, 86 | ...: kind='kde') 87 | In [30]: sns.jointplot(x='mpg', y='wt', 88 | ...: data=mtcars, 89 | ...: kind='reg') 90 | In [31]: from plotnine import * 91 | In [32]: from plotnine.data import mtcars 92 | In [33]: (ggplot(mtcars, aes('wt', 'mpg', color='factor(gear)')) 93 | ...: + geom_point() 94 | ...: + stat_smooth(method='lm') 95 | ...: + facet_wrap('~gear')) 96 | In [34]: mtcars.head() 97 | # Out[34]: 98 | mpg cyl disp hp drat wt qsec vs am gear carb 99 | 0 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4 100 | 1 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4 101 | 2 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1 102 | 3 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1 103 | 4 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2 104 | In [35]: (ggplot(mtcars, aes(x='wt', y='mpg')) 105 | ...: + geom_point()) 106 | In [36]: ggplot(mtcars, aes(x='wt', y='mpg')) 107 | In [37]: ggplot(mtcars, aes(x='wt', y='mpg')) + geom_point() 108 | In [38]: ggplot(mtcars, aes(x='wt', y='mpg')) + geom_line() 109 | In [39]: (ggplot(mtcars, aes(x='wt', y='mpg')) 110 | ...: + geom_smooth(method="lm")) 111 | In [40]: (ggplot(mtcars, aes(x='wt', y='mpg')) 112 | ...: + geom_smooth(method="lm") 113 | ...: + geom_point()) 114 | In [41]: (ggplot(mtcars, aes(x='wt', y='mpg')) 115 | ...: + geom_smooth(method="lm", color='red') 116 | ...: + geom_point(color='blue')) 117 | In [42]: (ggplot(mtcars, aes(x='wt', y='mpg')) 118 | ...: + geom_smooth(method="lm", color="red") 119 | ...: + geom_point(color="blue") 120 | ...: + labs(title="Automobie Data", x="Weight", y="Miles Per Gallon")) 121 | In [43]: (ggplot(mtcars, aes(x='hp', y='mpg', 122 | ...: shape='factor(cyl)', color='factor(cyl)')) + 123 | ...: geom_point(size=3) + 124 | ...: facet_grid('am~vs') + 125 | ...: labs(title="Automobile Data by Engine Type", 126 | ...: x="Horsepower", y="Miles Per Gallon")) 127 | In [44]: (ggplot(mtcars, aes(x='hp', y='mpg', 128 | ...: shape='factor(cyl)', color='cyl')) + 129 | ...: geom_point(size=3) + 130 | ...: facet_grid('am~vs') + 131 | ...: labs(title="Automobile Data by Engine Type", 132 | ...: x="Horsepower", y="Miles Per Gallon")) 133 | In [45]: (ggplot(mtcars, aes(x='factor(cyl)', y='mpg')) 134 | ...: + geom_boxplot(fill='cornflowerblue', color='black', notch=True) 135 | ...: + geom_point(position='jitter', color='blue', alpha=0.5) 136 | ...: + geom_rug(sides='l', color='black')) 137 | In [46]: from bokeh.io import output_notebook, show 138 | In [47]: from bokeh.plotting import figure 139 | In [48]: output_notebook() 140 | Loading BokehJS ... 141 | In [49]: # 步骤1:使用 figure() 创建图形对象 142 | ...: # 并指定图形的宽高 143 | ...: p = figure(plot_width=400, plot_height=400) 144 | ...: # 步骤2:添加图形元素 145 | ...: # 这里绘制点并指定点的一些属性 146 | ...: # 包括大小、颜色和透明度 147 | ...: p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], 148 | ...: size=15, line_color="navy", 149 | ...: fill_color="orange", fill_alpha=0.5) 150 | ...: # 步骤3:展示图形 151 | ...: show(p) 152 | In [50]: p = figure(plot_width=400, plot_height=400) 153 | ...: p.square([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], 154 | ...: size=15, color="firebrick", fill_alpha=0.5) 155 | ...: show(p) 156 | In [51]: p = figure(plot_width=400, plot_height=400) 157 | ...: p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], 158 | ...: line_width=2) 159 | ...: show(p) 160 | In [52]: # 构建数据 161 | ...: x = [1, 2, 3, 4, 5] 162 | ...: y = [6, 7, 8, 7, 3] 163 | ...: # 步骤1: 164 | ...: p = figure(plot_width=400, plot_height=400) 165 | ...: # 步骤2: 166 | ...: p.line(x, y, line_width=2) 167 | ...: p.circle(x, y, fill_color="white", size=8) 168 | ...: # 步骤3: 169 | ...: show(p) 170 | In [53]: # 构建数据 171 | ...: x = [1, 2, 3, 4, 5] 172 | ...: y = [6, 7, 8, 7, 3] 173 | ...: # 绘制图形 1 174 | ...: p1 = figure(plot_width=150, plot_height=150) 175 | ...: p1.circle(x, y, 176 | ...: size=5, line_color="navy", 177 | ...: fill_color="orange", fill_alpha=0.5) 178 | ...: # 绘制图形 2 179 | ...: p2 = figure(plot_width=150, plot_height=150) 180 | ...: p2.square(x, y, 181 | ...: size=5, color="firebrick", fill_alpha=0.5) 182 | ...: # 绘制图形 3 183 | ...: p3 = figure(plot_width=150, plot_height=150) 184 | ...: p3.line(x, y, line_width=2) 185 | In [54]: from bokeh.layouts import row, column 186 | ...: # 水平排列 187 | ...: show(row(p1, p2, p3)) 188 | In [55]: # 垂直排列 189 | ...: show(column(p1, p2, p3)) 190 | In [56]: from bokeh.layouts import gridplot 191 | ...: p = gridplot([[p1, p2], [p3, None]], toolbar_location=None) 192 | ...: show(p) 193 | -------------------------------------------------------------------------------- /docs/code_py/14-stats.py: -------------------------------------------------------------------------------- 1 | In [1]: import statistics as st # 标准库 2 | ...: import numpy as np 3 | ...: import pandas as pd 4 | ...: mtcars = pd.read_csv('files/chapter10/mtcars.csv') 5 | In [2]: st.mean([1, 2, 3]) # 标准库计算 6 | # Out[2]: 2 7 | In [3]: np.mean([1, 2, 3]) # NumPy 库计算# Out[3]: 2.0 8 | In [4]: pd.Series([1, 2, 3]).mean() # Pandas 库计算 9 | # Out[4]: 2.0 10 | In [5]: def geo_mean(iterable): 11 | ...: a = np.log(iterable) 12 | ...: return np.exp(a.sum()/len(a)) 13 | In [6]: geo_mean([1, 2, 3]) 14 | # Out[6]: 1.8171205928321397 15 | In [7]: from scipy.stats.mstats import gmean 16 | ...: gmean([1, 2, 3]) 17 | # Out[7]: 1.8171205928321397 18 | In [8]: st.median([1, 2, 1000]) 19 | # Out[8]: 2 20 | In [9]: np.median([1, 2, 1000]) 21 | # Out[9]: 2.0 22 | In [10]: pd.Series([1, 2, 3, 1000]).median() 23 | # Out[10]: 2.5 24 | In [11]: pd.Series([1, 2, 2, 3, 3, 5]).mode() 25 | # Out[11]: 26 | 0 2 27 | 1 3 28 | dtype: int64 29 | In [12]: a = [1, 2, 3, 1000] ...: max(a) - min(a) 30 | # Out[12]: 999 31 | In [13]: pd.Series([1, 2, 3, 1]).var() 32 | # Out[13]: 0.9166666666666666 33 | In [14]: pd.Series([1, 2, 3, 1000]).var() 34 | # Out[14]: 249001.66666666666 35 | In [15]: pd.Series([1, 2, 3, 1]).std() 36 | # Out[15]: 0.9574271077563381 37 | In [16]: mtcars.describe() 38 | # Out[16]: 39 | mpg cyl disp ... am gear carb 40 | count 32.000000 32.000000 32.000000 ... 32.000000 32.000000 32.0000 41 | mean 20.090625 6.187500 230.721875 ... 0.406250 3.687500 2.8125 42 | std 6.026948 1.785922 123.938694 ... 0.498991 0.737804 1.6152 43 | min 10.400000 4.000000 71.100000 ... 0.000000 3.000000 1.0000 44 | 25% 15.425000 4.000000 120.825000 ... 0.000000 3.000000 2.0000 45 | 50% 19.200000 6.000000 196.300000 ... 0.000000 4.000000 2.0000 46 | 75% 22.800000 8.000000 326.000000 ... 1.000000 4.000000 4.0000 47 | max 33.900000 8.000000 472.000000 ... 1.000000 5.000000 8.0000 48 | 49 | [8 rows x 11 columns] 50 | In [17]: mtcars.wt.skew() 51 | # Out[17]: 0.4659161067929868 52 | In [18]: %matplotlib # Notebook 使用 %matplotlib inline 53 | ...: mtcars.wt.plot(kind='kde') 54 | In [19]: mtcars.wt.kurtosis() 55 | # Out[19]: 0.41659466963492564 56 | In [20]: mtcars.cyl.kurtosis() 57 | # Out[20]: -1.7627938970111958 58 | In [21]: mtcars.cyl.plot(kind='kde') 59 | In [22]: from scipy import stats 60 | ...: import matplotlib.pyplot as plt 61 | ...: mu = 0 # 均值 62 | ...: sigma = 1 # 标准差 63 | ...: x = np.arange(-5,5,0.1) 64 | ...: y = stats.norm.pdf(x,mu,sigma) # 生成正态分布概率函数值 65 | ...: plt.plot(x, y) 66 | ...: plt.title('Normal: $\mu$=%.1f, $\sigma^2$=%.1f' % (mu,sigma)) 67 | ...: plt.xlabel('x') 68 | ...: plt.ylabel('Probability density', fontsize=15) 69 | ...: plt.show() 70 | In [23]: # 使用rvs()函数模拟一个二项随机变量 71 | ...: data = stats.binom.rvs(n=10,p=0.5,size=10) 72 | ...: 73 | ...: plt.hist(data, density=True) 74 | ...: plt.xlabel('x') 75 | ...: plt.ylabel('Probability density', fontsize=15) 76 | ...: plt.title('Binormal: n=10,$p$=0.5') 77 | ...: plt.show() 78 | In [24]: data = stats.binom.rvs(n=10,p=0.5,size=1000) 79 | ...: plt.hist(data, density=True) 80 | ...: plt.xlabel('x') 81 | ...: plt.ylabel('Probability density', fontsize=15) 82 | ...: plt.title('Binormal: n=10,$p$=0.5') 83 | ...: plt.show() 84 | In [25]: data = stats.bernoulli.rvs(p=0.6, size=10) 85 | ...: plt.hist(data) 86 | ...: plt.xlabel('x') 87 | ...: plt.ylabel('Frequency', fontsize=15) 88 | ...: plt.title('Bernouli: $p$=0.5') 89 | ...: plt.show() 90 | In [26]: data = stats.expon.rvs(scale=2,size=1000) # scale参数表示λ的倒数 91 | ...: plt.hist(data, density=True, bins=20) 92 | ...: plt.xlabel('x') 93 | ...: plt.ylabel('Probability density', fontsize=15) 94 | ...: plt.title('Exponential: 1/$\lambda$=2') 95 | ...: plt.show() 96 | In [27]: data = stats.poisson.rvs(mu=2,size=1000) # scale参数表示λ的倒数 97 | ...: plt.hist(data, density=True, bins=20) 98 | ...: plt.xlabel('x') 99 | ...: plt.ylabel('Probability density', fontsize=15) 100 | ...: plt.title('Poisson: $\lambda$=2') 101 | ...: plt.show() 102 | In [28]: from scipy import stats 103 | ...: height = [1.75, 1.58, 1.71, 1.64, 1.55, 1.72, 1.62, 1.83, 1.63, 1.65] 104 | ...: print(stats.ttest_1samp(height, 1.60)) 105 | Ttest_1sampResult(statistic=2.550797248729806, pvalue=0.03115396848888224) 106 | In [29]: quality_A = stats.norm.rvs(loc = 9,scale = 10,size = 500) 107 | ...: quality_B = stats.norm.rvs(loc = 7,scale = 10,size = 500) 108 | ...: 109 | ...: _ = plt.hist(quality_A, density=True, alpha=0.5) 110 | ...: _ = plt.hist(quality_B, density=True, color="red", alpha=0.5) 111 | -------------------------------------------------------------------------------- /docs/code_py/15-append.py: -------------------------------------------------------------------------------- 1 | %paste # 粘贴代码 2 | %run # 执行外部脚本 3 | %timeit # 计算代码运行时间 4 | %magic # 获取可用魔术命令描述与示例 5 | %lsmagic # 获取可用魔术命令列表 6 | %ls # 列出当前目录列表 7 | %pwd # 获取当前所在(工作)目录 8 | %cd # 切换工作目录 9 | %mkdir # 创建文件夹 10 | %cp # 拷贝文件 11 | %rm # 删除文件 12 | In [4]: %lsmagic 13 | # Out[4]: 14 | Available line magics: 15 | %alias %alias_magic %autoawait %autocall %autoindent %automagic %bookmark %cat %cd %clear %colors %conda %config %cp %cpaste %debug %dhist %dirs %doctest_mode %ed %edit %env %gui %hist %history %killbgscripts %ldir %less %lf %lk %ll %load %load_ext %loadpy %logoff %logon %logstart %logstate %logstop %ls %lsmagic %lx %macro %magic %m 16 | an %matplotlib %mkdir %more %mv %notebook %page %paste %pastebin %pdb %pdef %pdoc %pfile %pinfo %pinfo2 %pip %popd %pprint %precision %prun %psearch %psource %pushd % 17 | pwd %pycat %pylab %quickref %recall %rehashx %reload_ext %rep %rerun %reset %reset_selective %rm %rmdir %run %save %sc %set_env %store %sx %system %tb %time %timeit % 18 | unalias %unload_ext %who %who_ls %whos %xdel %xmode 19 | 20 | Available cell magics: 21 | %%! %%HTML %%SVG %%bash %%capture %%debug %%file %%html %%javascript %%js %%latex %%markdown %%perl %%prun %%pypy %%python %%python2 %%python3 %%ruby %%script %%sh %%sv 22 | g %%sx %%system %%time %%timeit %%writefile 23 | 24 | Automagic is ON, % prefix IS NOT needed for line magics. 25 | In [5]: %ls? 26 | Repr: 27 | In [6]: %ls 28 | 29 | In [7]: %mkdir new 30 | In [8]: %ls 31 | new/ 32 | In [9]: %pwd 33 | # Out[9]: '/home/shixiang/Proj/pybook/test_ipython_shell' 34 | In [10]: %cd new 35 | /home/shixiang/Proj/pybook/test_ipython_shell/new 36 | In [11]: %pwd 37 | # Out[11]: '/home/shixiang/Proj/pybook/test_ipython_shell/new' 38 | In [12]: %timeit Result = [i ** 2 for i in range(100)] 39 | 47.6 µs ± 386 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each) 40 | In [13]: %%timeit 41 | ...: Result = [] 42 | ...: for i in range(100): 43 | ...: Result.append(i * i) 44 | ...: 45 | 16.7 µs ± 178 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each) 46 | In [1]: class Student: 47 | ...: def __init__(self, name, age, height, score): 48 | ...: self.name = name 49 | ...: self.age = age 50 | ...: self.height = height 51 | ...: self.score = score 52 | In [2]: Student('小周', 20, 180, 98) 53 | # Out[2]: <__main__.Student at 0x7fe95c4eeb50> 54 | In [3]: zhou = Student('小周', 20, 180, 98) 55 | In [4]: zhou.score 56 | # Out[4]: 98 57 | In [5]: zhou.height 58 | # Out[5]: 180 59 | In [6]: zhou.age 60 | # Out[6]: 20 61 | In [7]: class Student: 62 | ...: def __init__(self, name, age, height, score): 63 | ...: self.name = name 64 | ...: self.age = age 65 | ...: self.height = height 66 | ...: self.score = score 67 | ...: def diff(self, average_score): 68 | ...: print(self.score - average_score) 69 | ...: 70 | zhou = Student('小周', 20, 180, 98) 71 | In [9]: zhou.diff(70) 72 | 28 73 | In [15]: class Student2(Student): 74 | ...: def __init__(self, name, age, height, score, class_name, teacher_name): 75 | ...: Student.__init__(self, name, age, height, score) 76 | ...: self.class_name = class_name 77 | ...: self.teacher_name = teacher_name 78 | ...: 79 | In [16]: zhou = Student2('小周', 20, 180, 98, "Class A", "Mr. Zhang") 80 | In [17]: zhou.name 81 | # Out[17]: '小周' 82 | In [18]: zhou.diff(70) 83 | 28 84 | -------------------------------------------------------------------------------- /docs/collect_figs.py: -------------------------------------------------------------------------------- 1 | import shutil, sys, os 2 | 3 | with open("./fig_header.txt", mode="r", encoding="utf-8") as f: 4 | contents = f.readlines() 5 | 6 | useful_text = [] 7 | 8 | for i in contents: 9 | if i == "\n": 10 | pass 11 | else: 12 | if i.startswith("File") or i.startswith("!["): 13 | useful_text += i.splitlines() 14 | else: 15 | pass 16 | 17 | chunks = "".join(useful_text).split("File ") 18 | for chunk in chunks: 19 | if chunk.endswith(".md") or chunk == "": 20 | continue 21 | fn, *figs = tuple(chunk.split('![')) 22 | print("=> Processing file", fn, "...") 23 | dirname = "./figures/chapter" + fn.split("-")[0] 24 | print("==> Creating ", dirname) 25 | os.makedirs(dirname) 26 | for fig in figs: 27 | fig_name, fig_loc = tuple(fig.split("](")) 28 | if fig_loc.endswith(")"): 29 | fig_loc = fig_loc[:-1] 30 | print("==> Found figure title %s and path %s" %(fig_name, fig_loc)) 31 | print("==> Processing ...") 32 | if fig_loc.endswith("png"): 33 | shutil.copy(fig_loc, dirname + "/" + fig_name + ".png") 34 | elif fig_loc.endswith("jpg"): 35 | shutil.copy(fig_loc, dirname + "/" + fig_name + ".jpg") 36 | else: 37 | print("Something is not captured for ", fig_loc) 38 | sys.exit(1) 39 | 40 | -------------------------------------------------------------------------------- /docs/example/H1_Strain.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/example/H1_Strain.wav -------------------------------------------------------------------------------- /docs/example/L1_Strain.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/example/L1_Strain.wav -------------------------------------------------------------------------------- /docs/example/first.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/example/first.pdf -------------------------------------------------------------------------------- /docs/example/first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/example/first.png -------------------------------------------------------------------------------- /docs/fig_header.txt: -------------------------------------------------------------------------------- 1 | 2 | File 01-introduction.md 3 | 4 | ![图1-1 Jupyter官方提供的Python在线Notebook页面](images/chapter1/Online_jupyter.png) 5 | ![图1-2 微软Jupyter数据科学学习平台](images/chapter1/Online_jupyter_Miscrosoft.png) 6 | ![图1-3 nteract官网页面](images/chapter1/nteract_web.png) 7 | ![图1-4 nteract官网页面](images/chapter1/download_anaconda_0.png) 8 | ![图1-5 nteract官网页面](images/chapter1/download_anaconda_win.png) 9 | ![图1-6 点击 Next ](images/chapter1/install_anaconda_win_1.png) 10 | ![图1-7 点击 I Agree ](images/chapter1/install_anaconda_win_2.png) 11 | ![图1-8 选择合适的安装类型](images/chapter1/install_anaconda_win_3.png) 12 | ![图1-9 选择合适的安装位置](images/chapter1/install_anaconda_win_4.png) 13 | ![图1-10 选择合适的安装位置](images/chapter1/install_anaconda_win_5.png) 14 | ![图1-11 安装进度](images/chapter1/install_anaconda_win_6.png) 15 | ![图1-12 安装进度条完成](images/chapter1/install_anaconda_win_7.png) 16 | ![图1-13 跳过安装 Visual Studio Code](images/chapter1/install_anaconda_win_8.png) 17 | ![图1-14 本地浏览器 Jupyter Notebook 主页](images/chapter1/nb_home.png) 18 | ![图1-15 nteract 界面](images/chapter1/use_nteract_0.png) 19 | ========== 20 | 21 | File 02-base.md 22 | 23 | ![图2-1 入门示例:向屏幕输出文字](images/chapter2/nteract_hello_world.png) 24 | ![图2-2 错误的示例](images/chapter2/nteract_hello_world_wrong.png) 25 | ![图2-3 单元格](images/chapter2/nteract_cell.png) 26 | ![图2-4 保存为 Jupyter 笔记本](images/chapter2/nteract_save.jpg) 27 | ![图2-5 Python中的四则运算](images/chapter2/nteract_sg_calc.png) 28 | ![图2-6 整除与求余](images/chapter2/nteract_sg_calc2.png) 29 | ![图2-7 作者的BMI指数](images/chapter2/nteract_My_bmi.png) 30 | ========== 31 | 32 | File 03-data-structure.md 33 | 34 | ========== 35 | 36 | File 04-control-flow.md 37 | 38 | ========== 39 | 40 | File 05-function-and-module.md 41 | 42 | ![图5-1 递归可视化:捧着画框的蒙娜丽莎 (图片来自网络)](images/chapter5/mnlisha.png) 43 | ========== 44 | 45 | File 06-numpy.md 46 | 47 | ========== 48 | 49 | File 07-matplotlib.md 50 | 51 | ![图7-1 使用脚本绘制图形结果](assets/1565968443953.png) 52 | ![图7-2 使用 Notebook 绘制图形结果](assets/1566008307111.png) 53 | ![图7-3 使用 MATLAB 样式绘图](assets/1566009197372.png) 54 | ![图7-4 简单线图,使用 range() 生成 x 轴数据](assets/1566009715829.png) 55 | ![图7-5 简单线图,使用 np.arange() 生成 x 轴数据](assets/1566009847601.png) 56 | ![图7-6 首先生成空白坐标轴](assets/1566010077143.png) 57 | ![图7-7 使用面向对象接口绘图](assets/1566010369211.png) 58 | ![图7-8 一图多曲线](assets/1566010491532.png) 59 | ![图7-9 线图颜色的使用](assets/1566010624845.png) 60 | ![图7-10 线图线条类型的使用](assets/1566010719188.png) 61 | ![图7-11 线图线条类型与颜色组合](assets/1566010869416.png) 62 | ![图7-12 图例的使用](assets/1566011014665.png) 63 | ![图7-13 线图自定义](assets/1566011155999.png) 64 | ![图7-14 线图用于趋势对比](assets/1566011228901.png) 65 | ![图7-15 添加坐标轴标签与标题](assets/1566011365121.png) 66 | ![图7-16 可视化特定区域](assets/1566011464100.png) 67 | ![图7-17 坐标轴反转](assets/1566011545524.png) 68 | ![图7-18 可视化特定区域(二)](assets/1566011646740.png) 69 | ![图7-19 去掉轴](assets/1566011764310.png) 70 | ![图7-20 使 x 轴 y 轴坐标一致](assets/1566011842818.png) 71 | ![图7-21 与屏幕一致的纵横比](assets/1566011901725.png) 72 | ![图7-22 默认选项](assets/1566012009692.png) 73 | ![图7-23 使用 plot() 函数绘制点图](assets/1566012156747.png) 74 | ![图7-24 使用 scatter() 函数绘制点图](assets/1566012247119.png) 75 | ![图7-25 点与符号](assets/1566012427766.png) 76 | ![图7-26 未设置透明度之前](assets/1566012512679.png) 77 | ![图7-27 设置透明度之后](assets/1566012584741.png) 78 | ![图7-28 设置点的大小和颜色](assets/1566012743480.png) 79 | ![图7-29 加上颜色条](assets/1566012814718.png) 80 | ![图7-30 垂直条形图示例](assets/1566013182248.png) 81 | ![图7-31 水平条形图示例](assets/1566013434471.png) 82 | ![图7-32 分组条形图示例](assets/1566013535017.png) 83 | ![图7-33 堆叠条形图示例](assets/1566013707092.png) 84 | ![图7-34 直方图](assets/1566029014148.png) 85 | ![图7-35 更改直方图的几个常用选项](assets/1566029142554.png) 86 | ![图7-36 使用直方图比较 3 个数据分布](assets/1566029266277.png) 87 | ![图7-37 二维直方图](assets/1566029521952.png) 88 | ![图7-38 饼图](assets/1566029603380.png) 89 | ![图7-39 职工学历分布](assets/1566030049989.png) 90 | ![图7-40 箱线图简单示例](assets/1566030181185.png) 91 | ![图7-41 使用箱线图进行比较](assets/1566030359191.png) 92 | ![图7-42 网格子图](assets/1566030513027.png) 93 | ![图7-43 调整子图间距](assets/1566030610383.png) 94 | ![图7-44 手动绘制子图](assets/1566030719209.png) 95 | ![图7-45 同享一个 x 轴](assets/1566030891387.png) 96 | ![图7-46 设置经典风格](assets/1566031061659.png) 97 | ![图7-47 使用 seaborn 库 white 风格](assets/1566031144809.png) 98 | ![图7-48 使用 ggplot 风格](assets/1566031232055.png) 99 | ![图7-49 使用 set() 方法设置图形](assets/1566031500991.png) 100 | ========== 101 | 102 | File 08-pandas-intro.md 103 | 104 | ========== 105 | 106 | File 09-markdown.md 107 | 108 | ![图9-1 标题预览](assets/1565877938229.png) 109 | ![图9-2 列表预览](assets/1565878138608.png) 110 | ![图9-3 任务列表预览](assets/1565878216261.png) 111 | ![图9-4 代码块预览](assets/1565878297820.png) 112 | ![图9-5 公式预览](assets/1565878448091.png) 113 | ![图9-6 表格预览](assets/1565878505816.png) 114 | ![图9-7 表格对齐预览](assets/1565878560237.png) 115 | ![图9-8 脚注预览](assets/1565878612454.png) 116 | ![图9-9 行内链接预览](assets/1565878849732.png) 117 | ![图9-10 参考链接预览](assets/1565878886705.png) 118 | ![图9-11 URL 预览](assets/1565878937914.png) 119 | ![图9-12 图片预览(图片来自网络)](assets/1565878990096.png) 120 | ![图9-13 nteract 显示的代码块](assets/1565881098150.png) 121 | ![图9-14 nteract 显示的文本块](assets/1565881258155.png) 122 | ![图9-15 Notebook 书写简单示例](assets/1565883426201.png) 123 | ![图9-16 Notebook 示例(一)](assets/1565965546720.png) 124 | ![图9-17 Notebook 示例(二)](assets/1565965576073.png) 125 | ========== 126 | 127 | File 10-data-import.md 128 | 129 | ![图10-1 HDF5 存储的时间序列数据可视化](images/chapter10/hdf5_time_series.png) 130 | ========== 131 | 132 | File 11-toolbox.md 133 | 134 | ========== 135 | 136 | File 12-advanced-pandas.md 137 | 138 | ![图12-1 Numpy 数组与 Pandas 数据结构对比(图片来自网络)](images/chapter12/numpy_pandas_comparison.png) 139 | ![图12-2 使用 plot 方法自动生成线图](12-advanced-pandas.assets/image-20191230003925736.png) 140 | ![图12-3 条形图](12-advanced-pandas.assets/image-20191230004055880.png) 141 | ![图12-4 水平条形图](12-advanced-pandas.assets/image-20191230004143103.png) 142 | ![图12-5 堆叠条形图](12-advanced-pandas.assets/image-20191230004245577.png) 143 | ![图12-6 直方图](12-advanced-pandas.assets/image-20191230004347306.png) 144 | ![图12-7 直方图,设置条形数量](12-advanced-pandas.assets/image-20191230004432888.png) 145 | ![图12-8 分组直方图](12-advanced-pandas.assets/image-20191230004515958.png) 146 | ![图12-9 箱线图](12-advanced-pandas.assets/image-20191230004552654.png) 147 | ![图12-10 分组箱线图](12-advanced-pandas.assets/image-20191230004636247.png) 148 | ![图12-11 面积图](12-advanced-pandas.assets/image-20191230004751906.png) 149 | ![图12-12 散点图](12-advanced-pandas.assets/image-20191230004830637.png) 150 | ![图12-13 饼图](12-advanced-pandas.assets/image-20191230004907721.png) 151 | ![图12-14 饼图(2)](12-advanced-pandas.assets/image-20191230004953542.png) 152 | ========== 153 | 154 | File 13-advanced-vis.md 155 | 156 | ![图13-1 mtcars 数据集变量成对相关图](13-advanced-vis.assets/image-20191230215115722.png) 157 | ![图13-2 mtcars 数据集相关图选择性展示](13-advanced-vis.assets/sns-col3-7.png) 158 | ![图13-3 wt 与 mpg 成对相关图](13-advanced-vis.assets/image-20191230215554306.png) 159 | ![图13-4 按 cyl 分组成对相关图](13-advanced-vis.assets/sns-add-cyl.png) 160 | ![图13-5 风格调整](13-advanced-vis.assets/image-20191230215943127.png) 161 | ![图13-6 子集图](13-advanced-vis.assets/image-20191230220723864.png) 162 | ![图13-7 子集图(2)](13-advanced-vis.assets/image-20191230221009007.png) 163 | ![图13-8 回归图](13-advanced-vis.assets/image-20191230221207470.png) 164 | ![图13-9 核密度图](13-advanced-vis.assets/image-20191230221500314.png) 165 | ![图13-10 条形图](13-advanced-vis.assets/image-20191230221600624.png) 166 | ![图13-11 分组条形图](13-advanced-vis.assets/image-20191230221709623.png) 167 | ![图13-12 计数图](13-advanced-vis.assets/image-20191230221756287.png) 168 | ![图13-13 点图](13-advanced-vis.assets/image-20191230222028538.png) 169 | ![图13-14 箱线图](13-advanced-vis.assets/image-20191230222135759.png) 170 | ![图13-15 小提琴图](13-advanced-vis.assets/image-20191231001708117.png) 171 | ![图13-16 双变量分布图展示核密度](13-advanced-vis.assets/image-20191230222321813.png) 172 | ![图13-17 双变量分布图展示分布和线性回归](13-advanced-vis.assets/image-20191230222426218.png) 173 | ![图13-18 plotnine 示例](13-advanced-vis.assets/image-20191230222708685.png) 174 | ![图13-19 ggplot 点图](13-advanced-vis.assets/image-20191230223148915.png) 175 | ![图13-20 ggplot 画布](13-advanced-vis.assets/image-20191230223250156.png) 176 | ![图13-21 ggplot 点图实现](13-advanced-vis.assets/image-20191230223419554.png) 177 | ![图13-22 ggplot 线图](13-advanced-vis.assets/image-20191230223457527.png) 178 | ![图13-23 ggplot 线性回归](13-advanced-vis.assets/image-20191230223557348.png) 179 | ![图13-24 ggplot 点图加线性回归](13-advanced-vis.assets/image-20191230223710925.png) 180 | ![图13-25 ggplot 修改图形参数](13-advanced-vis.assets/image-20191230223842550.png) 181 | ![图13-26 ggplot 修改引导元素](13-advanced-vis.assets/image-20191230224044284.png) 182 | ![图13-27 ggplot 分面图](13-advanced-vis.assets/image-20191230224254356.png) 183 | ![图13-28 ggplot 错误分面图](13-advanced-vis.assets/image-20191230224358512.png) 184 | ![图13-29 ggplot 组合实例](13-advanced-vis.assets/image-20191230224528932.png) 185 | ![图13-30 Bokeh 散点图](13-advanced-vis.assets/image-20191230225221554.png) 186 | ![图13-31 Bokeh 线图](13-advanced-vis.assets/image-20191230225458923.png) 187 | ![图13-32 Bokeh 组合图](13-advanced-vis.assets/image-20191230225647464.png) 188 | ![图13-33 Bokeh 水平排列](13-advanced-vis.assets/image-20191230230129141.png) 189 | ![图13-34 Bokeh 垂直排列](13-advanced-vis.assets/image-20191230230214815.png) 190 | ![图13-35 Bokeh 网格排列](13-advanced-vis.assets/image-20191230230300868.png) 191 | ========== 192 | 193 | File 14-stats.md 194 | 195 | ![图14-1 汽车数据集变量 wt 分布图](14-stats.assets/image-20191230232350998.png) 196 | ![图14-2 汽车数据集变量 cyl 分布图](14-stats.assets/image-20191230232550894.png) 197 | ![图14-3 标准正态分布](14-stats.assets/image-20191230233657424.png) 198 | ![图14-4 二项分布](14-stats.assets/image-20191230234020193.png) 199 | ![图14-5 二项分布(2)](14-stats.assets/image-20191230234149623.png) 200 | ![图14-6 伯努利分布](14-stats.assets/image-20191230234242528.png) 201 | ![图14-7 指数分布](14-stats.assets/image-20191231003035336.png) 202 | ![图14-8 泊松分布](14-stats.assets/image-20191231003204811.png) 203 | ![图14-9 标准正态分布经验法则图示(图片来自网络)](14-stats.assets/1000.jpg) 204 | ![图14-10 两样本数据分布直方图](14-stats.assets/image-20191230234822443.png) 205 | ========== 206 | 207 | File 15-append.md 208 | 209 | ========== 210 | 211 | File 16-end.md 212 | 213 | ========== 214 | -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-1 Jupyter官方提供的Python在线Notebook页面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-1 Jupyter官方提供的Python在线Notebook页面.png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-10 选择合适的安装位置.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-10 选择合适的安装位置.png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-11 安装进度.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-11 安装进度.png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-12 安装进度条完成.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-12 安装进度条完成.png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-13 跳过安装 Visual Studio Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-13 跳过安装 Visual Studio Code.png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-14 本地浏览器 Jupyter Notebook 主页.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-14 本地浏览器 Jupyter Notebook 主页.png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-15 nteract 界面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-15 nteract 界面.png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-2 微软Jupyter数据科学学习平台.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-2 微软Jupyter数据科学学习平台.png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-3 nteract官网页面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-3 nteract官网页面.png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-4 nteract官网页面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-4 nteract官网页面.png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-5 nteract官网页面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-5 nteract官网页面.png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-6 点击 Next .png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-6 点击 Next .png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-7 点击 I Agree .png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-7 点击 I Agree .png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-8 选择合适的安装类型.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-8 选择合适的安装类型.png -------------------------------------------------------------------------------- /docs/figures/chapter01/图1-9 选择合适的安装位置.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter01/图1-9 选择合适的安装位置.png -------------------------------------------------------------------------------- /docs/figures/chapter02/图2-1 入门示例:向屏幕输出文字.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter02/图2-1 入门示例:向屏幕输出文字.png -------------------------------------------------------------------------------- /docs/figures/chapter02/图2-2 错误的示例.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter02/图2-2 错误的示例.png -------------------------------------------------------------------------------- /docs/figures/chapter02/图2-3 单元格.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter02/图2-3 单元格.png -------------------------------------------------------------------------------- /docs/figures/chapter02/图2-4 保存为 Jupyter 笔记本.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter02/图2-4 保存为 Jupyter 笔记本.jpg -------------------------------------------------------------------------------- /docs/figures/chapter02/图2-5 Python中的四则运算.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter02/图2-5 Python中的四则运算.png -------------------------------------------------------------------------------- /docs/figures/chapter02/图2-6 整除与求余.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter02/图2-6 整除与求余.png -------------------------------------------------------------------------------- /docs/figures/chapter02/图2-7 作者的BMI指数.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter02/图2-7 作者的BMI指数.png -------------------------------------------------------------------------------- /docs/figures/chapter05/图5-1 递归可视化:捧着画框的蒙娜丽莎 (图片来自网络).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter05/图5-1 递归可视化:捧着画框的蒙娜丽莎 (图片来自网络).png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-1 使用脚本绘制图形结果.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-1 使用脚本绘制图形结果.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-10 线图线条类型的使用.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-10 线图线条类型的使用.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-11 线图线条类型与颜色组合.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-11 线图线条类型与颜色组合.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-12 图例的使用.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-12 图例的使用.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-13 线图自定义.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-13 线图自定义.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-14 线图用于趋势对比.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-14 线图用于趋势对比.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-15 添加坐标轴标签与标题.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-15 添加坐标轴标签与标题.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-16 可视化特定区域.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-16 可视化特定区域.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-17 坐标轴反转.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-17 坐标轴反转.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-18 可视化特定区域(二).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-18 可视化特定区域(二).png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-19 去掉轴.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-19 去掉轴.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-2 使用 Notebook 绘制图形结果.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-2 使用 Notebook 绘制图形结果.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-20 使 x 轴 y 轴坐标一致.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-20 使 x 轴 y 轴坐标一致.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-21 与屏幕一致的纵横比.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-21 与屏幕一致的纵横比.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-22 默认选项.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-22 默认选项.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-23 使用 plot() 函数绘制点图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-23 使用 plot() 函数绘制点图.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-24 使用 scatter() 函数绘制点图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-24 使用 scatter() 函数绘制点图.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-25 点与符号.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-25 点与符号.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-26 未设置透明度之前.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-26 未设置透明度之前.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-27 设置透明度之后.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-27 设置透明度之后.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-28 设置点的大小和颜色.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-28 设置点的大小和颜色.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-29 加上颜色条.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-29 加上颜色条.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-3 使用 MATLAB 样式绘图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-3 使用 MATLAB 样式绘图.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-30 垂直条形图示例.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-30 垂直条形图示例.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-31 水平条形图示例.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-31 水平条形图示例.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-32 分组条形图示例.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-32 分组条形图示例.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-33 堆叠条形图示例.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-33 堆叠条形图示例.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-34 直方图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-34 直方图.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-35 更改直方图的几个常用选项.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-35 更改直方图的几个常用选项.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-36 使用直方图比较 3 个数据分布.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-36 使用直方图比较 3 个数据分布.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-37 二维直方图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-37 二维直方图.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-38 饼图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-38 饼图.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-39 职工学历分布.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-39 职工学历分布.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-4 简单线图,使用 range() 生成 x 轴数据.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-4 简单线图,使用 range() 生成 x 轴数据.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-40 箱线图简单示例.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-40 箱线图简单示例.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-41 使用箱线图进行比较.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-41 使用箱线图进行比较.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-42 网格子图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-42 网格子图.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-43 调整子图间距.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-43 调整子图间距.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-44 手动绘制子图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-44 手动绘制子图.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-45 同享一个 x 轴.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-45 同享一个 x 轴.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-46 设置经典风格.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-46 设置经典风格.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-47 使用 seaborn 库 white 风格.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-47 使用 seaborn 库 white 风格.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-48 使用 ggplot 风格.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-48 使用 ggplot 风格.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-49 使用 set() 方法设置图形.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-49 使用 set() 方法设置图形.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-5 简单线图,使用 np.arange() 生成 x 轴数据.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-5 简单线图,使用 np.arange() 生成 x 轴数据.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-6 首先生成空白坐标轴.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-6 首先生成空白坐标轴.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-7 使用面向对象接口绘图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-7 使用面向对象接口绘图.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-8 一图多曲线.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-8 一图多曲线.png -------------------------------------------------------------------------------- /docs/figures/chapter07/图7-9 线图颜色的使用.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter07/图7-9 线图颜色的使用.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-1 标题预览.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-1 标题预览.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-10 参考链接预览.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-10 参考链接预览.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-11 URL 预览.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-11 URL 预览.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-12 图片预览(图片来自网络).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-12 图片预览(图片来自网络).png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-13 nteract 显示的代码块.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-13 nteract 显示的代码块.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-14 nteract 显示的文本块.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-14 nteract 显示的文本块.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-15 Notebook 书写简单示例.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-15 Notebook 书写简单示例.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-16 Notebook 示例(一).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-16 Notebook 示例(一).png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-17 Notebook 示例(二).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-17 Notebook 示例(二).png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-2 列表预览.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-2 列表预览.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-3 任务列表预览.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-3 任务列表预览.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-4 代码块预览.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-4 代码块预览.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-5 公式预览.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-5 公式预览.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-6 表格预览.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-6 表格预览.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-7 表格对齐预览.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-7 表格对齐预览.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-8 脚注预览.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-8 脚注预览.png -------------------------------------------------------------------------------- /docs/figures/chapter09/图9-9 行内链接预览.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter09/图9-9 行内链接预览.png -------------------------------------------------------------------------------- /docs/figures/chapter10/图10-1 HDF5 存储的时间序列数据可视化.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter10/图10-1 HDF5 存储的时间序列数据可视化.png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-1 Numpy 数组与 Pandas 数据结构对比(图片来自网络).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-1 Numpy 数组与 Pandas 数据结构对比(图片来自网络).png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-10 分组箱线图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-10 分组箱线图.png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-11 面积图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-11 面积图.png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-12 散点图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-12 散点图.png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-13 饼图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-13 饼图.png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-14 饼图(2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-14 饼图(2).png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-2 使用 plot 方法自动生成线图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-2 使用 plot 方法自动生成线图.png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-3 条形图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-3 条形图.png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-4 水平条形图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-4 水平条形图.png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-5 堆叠条形图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-5 堆叠条形图.png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-6 直方图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-6 直方图.png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-7 直方图,设置条形数量.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-7 直方图,设置条形数量.png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-8 分组直方图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-8 分组直方图.png -------------------------------------------------------------------------------- /docs/figures/chapter12/图12-9 箱线图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter12/图12-9 箱线图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-1 mtcars 数据集变量成对相关图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-1 mtcars 数据集变量成对相关图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-10 条形图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-10 条形图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-11 分组条形图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-11 分组条形图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-12 计数图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-12 计数图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-13 点图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-13 点图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-14 箱线图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-14 箱线图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-15 小提琴图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-15 小提琴图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-16 双变量分布图展示核密度.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-16 双变量分布图展示核密度.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-17 双变量分布图展示分布和线性回归.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-17 双变量分布图展示分布和线性回归.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-18 plotnine 示例.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-18 plotnine 示例.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-19 ggplot 点图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-19 ggplot 点图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-2 mtcars 数据集相关图选择性展示.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-2 mtcars 数据集相关图选择性展示.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-20 ggplot 画布.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-20 ggplot 画布.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-21 ggplot 点图实现.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-21 ggplot 点图实现.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-22 ggplot 线图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-22 ggplot 线图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-23 ggplot 线性回归.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-23 ggplot 线性回归.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-24 ggplot 点图加线性回归.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-24 ggplot 点图加线性回归.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-25 ggplot 修改图形参数.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-25 ggplot 修改图形参数.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-26 ggplot 修改引导元素.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-26 ggplot 修改引导元素.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-27 ggplot 分面图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-27 ggplot 分面图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-28 ggplot 错误分面图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-28 ggplot 错误分面图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-29 ggplot 组合实例.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-29 ggplot 组合实例.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-3 wt 与 mpg 成对相关图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-3 wt 与 mpg 成对相关图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-30 Bokeh 散点图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-30 Bokeh 散点图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-31 Bokeh 线图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-31 Bokeh 线图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-32 Bokeh 组合图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-32 Bokeh 组合图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-33 Bokeh 水平排列.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-33 Bokeh 水平排列.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-34 Bokeh 垂直排列.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-34 Bokeh 垂直排列.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-35 Bokeh 网格排列.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-35 Bokeh 网格排列.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-4 按 cyl 分组成对相关图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-4 按 cyl 分组成对相关图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-5 风格调整.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-5 风格调整.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-6 子集图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-6 子集图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-7 子集图(2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-7 子集图(2).png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-8 回归图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-8 回归图.png -------------------------------------------------------------------------------- /docs/figures/chapter13/图13-9 核密度图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter13/图13-9 核密度图.png -------------------------------------------------------------------------------- /docs/figures/chapter14/图14-1 汽车数据集变量 wt 分布图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter14/图14-1 汽车数据集变量 wt 分布图.png -------------------------------------------------------------------------------- /docs/figures/chapter14/图14-10 两样本数据分布直方图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter14/图14-10 两样本数据分布直方图.png -------------------------------------------------------------------------------- /docs/figures/chapter14/图14-2 汽车数据集变量 cyl 分布图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter14/图14-2 汽车数据集变量 cyl 分布图.png -------------------------------------------------------------------------------- /docs/figures/chapter14/图14-3 标准正态分布.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter14/图14-3 标准正态分布.png -------------------------------------------------------------------------------- /docs/figures/chapter14/图14-4 二项分布.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter14/图14-4 二项分布.png -------------------------------------------------------------------------------- /docs/figures/chapter14/图14-5 二项分布(2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter14/图14-5 二项分布(2).png -------------------------------------------------------------------------------- /docs/figures/chapter14/图14-6 伯努利分布.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter14/图14-6 伯努利分布.png -------------------------------------------------------------------------------- /docs/figures/chapter14/图14-7 指数分布.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter14/图14-7 指数分布.png -------------------------------------------------------------------------------- /docs/figures/chapter14/图14-8 泊松分布.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter14/图14-8 泊松分布.png -------------------------------------------------------------------------------- /docs/figures/chapter14/图14-9 标准正态分布经验法则图示(图片来自网络).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/figures/chapter14/图14-9 标准正态分布经验法则图示(图片来自网络).jpg -------------------------------------------------------------------------------- /docs/files/chapter10/data.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/files/chapter10/data.db -------------------------------------------------------------------------------- /docs/files/chapter10/data.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/files/chapter10/data.hdf5 -------------------------------------------------------------------------------- /docs/files/chapter10/data.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 一个网页 6 | 7 | 8 |

第一个标题

9 |

第一个段落。

10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/files/chapter10/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "sites": [ 3 | { "名字": "Mike Wang" , "个人主页":"www.xxx.com" }, 4 | { "名字": "Mike Zhang" , "个人主页":"www.xx1.com" }, 5 | { "名字": "Mike Li" , "个人主页":"www.xx2.com" } 6 | ] 7 | } -------------------------------------------------------------------------------- /docs/files/chapter10/data.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/files/chapter10/data.pkl -------------------------------------------------------------------------------- /docs/files/chapter10/data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/files/chapter10/data.xlsx -------------------------------------------------------------------------------- /docs/files/chapter10/data1.yml: -------------------------------------------------------------------------------- 1 | 字符串: name 2 | 特殊: "name\n" 3 | 数值: 3.14 4 | 布尔值: true 5 | 空值: null 6 | 空值2: ~ 7 | 时间值: 2019-11-11t11:33:22.55-06:00 8 | 日期值: 2019-11-11 -------------------------------------------------------------------------------- /docs/files/chapter10/data2.yml: -------------------------------------------------------------------------------- 1 | user1: 2 | type: user 3 | name: a 4 | password: 123 5 | user2: 6 | type: user 7 | name: b 8 | password: 456 9 | user3: 10 | type: group 11 | name: 12 | - aa 13 | - bb 14 | - cc 15 | password: 16 | - 123 17 | - 456 18 | - null 19 | summary: 20 | - user1 21 | - user2 22 | - user3 -------------------------------------------------------------------------------- /docs/files/chapter10/lung.csv: -------------------------------------------------------------------------------- 1 | inst,time,status,age,sex,ph.ecog,ph.karno,pat.karno,meal.cal,wt.loss 2 | 3,306,2,74,1,1,90,100,1175,NA 3 | 3,455,2,68,1,0,90,90,1225,15 4 | 3,1010,1,56,1,0,90,90,NA,15 5 | 5,210,2,57,1,1,90,60,1150,11 6 | 1,883,2,60,1,0,100,90,NA,0 7 | 12,1022,1,74,1,1,50,80,513,0 8 | 7,310,2,68,2,2,70,60,384,10 9 | 11,361,2,71,2,2,60,80,538,1 10 | 1,218,2,53,1,1,70,80,825,16 11 | 7,166,2,61,1,2,70,70,271,34 12 | 6,170,2,57,1,1,80,80,1025,27 13 | 16,654,2,68,2,2,70,70,NA,23 14 | 11,728,2,68,2,1,90,90,NA,5 15 | 21,71,2,60,1,NA,60,70,1225,32 16 | 12,567,2,57,1,1,80,70,2600,60 17 | 1,144,2,67,1,1,80,90,NA,15 18 | 22,613,2,70,1,1,90,100,1150,-5 19 | 16,707,2,63,1,2,50,70,1025,22 20 | 1,61,2,56,2,2,60,60,238,10 21 | 21,88,2,57,1,1,90,80,1175,NA 22 | 11,301,2,67,1,1,80,80,1025,17 23 | 6,81,2,49,2,0,100,70,1175,-8 24 | 11,624,2,50,1,1,70,80,NA,16 25 | 15,371,2,58,1,0,90,100,975,13 26 | 12,394,2,72,1,0,90,80,NA,0 27 | 12,520,2,70,2,1,90,80,825,6 28 | 4,574,2,60,1,0,100,100,1025,-13 29 | 13,118,2,70,1,3,60,70,1075,20 30 | 13,390,2,53,1,1,80,70,875,-7 31 | 1,12,2,74,1,2,70,50,305,20 32 | 12,473,2,69,2,1,90,90,1025,-1 33 | 1,26,2,73,1,2,60,70,388,20 34 | 7,533,2,48,1,2,60,80,NA,-11 35 | 16,107,2,60,2,2,50,60,925,-15 36 | 12,53,2,61,1,2,70,100,1075,10 37 | 1,122,2,62,2,2,50,50,1025,NA 38 | 22,814,2,65,1,2,70,60,513,28 39 | 15,965,1,66,2,1,70,90,875,4 40 | 1,93,2,74,1,2,50,40,1225,24 41 | 1,731,2,64,2,1,80,100,1175,15 42 | 5,460,2,70,1,1,80,60,975,10 43 | 11,153,2,73,2,2,60,70,1075,11 44 | 10,433,2,59,2,0,90,90,363,27 45 | 12,145,2,60,2,2,70,60,NA,NA 46 | 7,583,2,68,1,1,60,70,1025,7 47 | 7,95,2,76,2,2,60,60,625,-24 48 | 1,303,2,74,1,0,90,70,463,30 49 | 3,519,2,63,1,1,80,70,1025,10 50 | 13,643,2,74,1,0,90,90,1425,2 51 | 22,765,2,50,2,1,90,100,1175,4 52 | 3,735,2,72,2,1,90,90,NA,9 53 | 12,189,2,63,1,0,80,70,NA,0 54 | 21,53,2,68,1,0,90,100,1025,0 55 | 1,246,2,58,1,0,100,90,1175,7 56 | 6,689,2,59,1,1,90,80,1300,15 57 | 1,65,2,62,1,0,90,80,725,NA 58 | 5,5,2,65,2,0,100,80,338,5 59 | 22,132,2,57,1,2,70,60,NA,18 60 | 3,687,2,58,2,1,80,80,1225,10 61 | 1,345,2,64,2,1,90,80,1075,-3 62 | 22,444,2,75,2,2,70,70,438,8 63 | 12,223,2,48,1,1,90,80,1300,68 64 | 21,175,2,73,1,1,80,100,1025,NA 65 | 11,60,2,65,2,1,90,80,1025,0 66 | 3,163,2,69,1,1,80,60,1125,0 67 | 3,65,2,68,1,2,70,50,825,8 68 | 16,208,2,67,2,2,70,NA,538,2 69 | 5,821,1,64,2,0,90,70,1025,3 70 | 22,428,2,68,1,0,100,80,1039,0 71 | 6,230,2,67,1,1,80,100,488,23 72 | 13,840,1,63,1,0,90,90,1175,-1 73 | 3,305,2,48,2,1,80,90,538,29 74 | 5,11,2,74,1,2,70,100,1175,0 75 | 2,132,2,40,1,1,80,80,NA,3 76 | 21,226,2,53,2,1,90,80,825,3 77 | 12,426,2,71,2,1,90,90,1075,19 78 | 1,705,2,51,2,0,100,80,1300,0 79 | 6,363,2,56,2,1,80,70,1225,-2 80 | 3,11,2,81,1,0,90,NA,731,15 81 | 1,176,2,73,1,0,90,70,169,30 82 | 4,791,2,59,1,0,100,80,768,5 83 | 13,95,2,55,1,1,70,90,1500,15 84 | 11,196,1,42,1,1,80,80,1425,8 85 | 21,167,2,44,2,1,80,90,588,-1 86 | 16,806,1,44,1,1,80,80,1025,1 87 | 6,284,2,71,1,1,80,90,1100,14 88 | 22,641,2,62,2,1,80,80,1150,1 89 | 21,147,2,61,1,0,100,90,1175,4 90 | 13,740,1,44,2,1,90,80,588,39 91 | 1,163,2,72,1,2,70,70,910,2 92 | 11,655,2,63,1,0,100,90,975,-1 93 | 22,239,2,70,1,1,80,100,NA,23 94 | 5,88,2,66,1,1,90,80,875,8 95 | 10,245,2,57,2,1,80,60,280,14 96 | 1,588,1,69,2,0,100,90,NA,13 97 | 12,30,2,72,1,2,80,60,288,7 98 | 3,179,2,69,1,1,80,80,NA,25 99 | 12,310,2,71,1,1,90,100,NA,0 100 | 11,477,2,64,1,1,90,100,910,0 101 | 3,166,2,70,2,0,90,70,NA,10 102 | 1,559,1,58,2,0,100,100,710,15 103 | 6,450,2,69,2,1,80,90,1175,3 104 | 13,364,2,56,1,1,70,80,NA,4 105 | 6,107,2,63,1,1,90,70,NA,0 106 | 13,177,2,59,1,2,50,NA,NA,32 107 | 12,156,2,66,1,1,80,90,875,14 108 | 26,529,1,54,2,1,80,100,975,-3 109 | 1,11,2,67,1,1,90,90,925,NA 110 | 21,429,2,55,1,1,100,80,975,5 111 | 3,351,2,75,2,2,60,50,925,11 112 | 13,15,2,69,1,0,90,70,575,10 113 | 1,181,2,44,1,1,80,90,1175,5 114 | 10,283,2,80,1,1,80,100,1030,6 115 | 3,201,2,75,2,0,90,100,NA,1 116 | 6,524,2,54,2,1,80,100,NA,15 117 | 1,13,2,76,1,2,70,70,413,20 118 | 3,212,2,49,1,2,70,60,675,20 119 | 1,524,2,68,1,2,60,70,1300,30 120 | 16,288,2,66,1,2,70,60,613,24 121 | 15,363,2,80,1,1,80,90,346,11 122 | 22,442,2,75,1,0,90,90,NA,0 123 | 26,199,2,60,2,2,70,80,675,10 124 | 3,550,2,69,2,1,70,80,910,0 125 | 11,54,2,72,1,2,60,60,768,-3 126 | 1,558,2,70,1,0,90,90,1025,17 127 | 22,207,2,66,1,1,80,80,925,20 128 | 7,92,2,50,1,1,80,60,1075,13 129 | 12,60,2,64,1,1,80,90,993,0 130 | 16,551,1,77,2,2,80,60,750,28 131 | 12,543,1,48,2,0,90,60,NA,4 132 | 4,293,2,59,2,1,80,80,925,52 133 | 16,202,2,53,1,1,80,80,NA,20 134 | 6,353,2,47,1,0,100,90,1225,5 135 | 13,511,1,55,2,1,80,70,NA,49 136 | 1,267,2,67,1,0,90,70,313,6 137 | 22,511,1,74,2,2,60,40,96,37 138 | 12,371,2,58,2,1,80,70,NA,0 139 | 13,387,2,56,1,2,80,60,1075,NA 140 | 1,457,2,54,1,1,90,90,975,-5 141 | 5,337,2,56,1,0,100,100,1500,15 142 | 21,201,2,73,2,2,70,60,1225,-16 143 | 3,404,1,74,1,1,80,70,413,38 144 | 26,222,2,76,1,2,70,70,1500,8 145 | 1,62,2,65,2,1,80,90,1075,0 146 | 11,458,1,57,1,1,80,100,513,30 147 | 26,356,1,53,2,1,90,90,NA,2 148 | 16,353,2,71,1,0,100,80,775,2 149 | 16,163,2,54,1,1,90,80,1225,13 150 | 12,31,2,82,1,0,100,90,413,27 151 | 13,340,2,59,2,0,100,90,NA,0 152 | 13,229,2,70,1,1,70,60,1175,-2 153 | 22,444,1,60,1,0,90,100,NA,7 154 | 5,315,1,62,2,0,90,90,NA,0 155 | 16,182,2,53,2,1,80,60,NA,4 156 | 32,156,2,55,1,2,70,30,1025,10 157 | NA,329,2,69,1,2,70,80,713,20 158 | 26,364,1,68,2,1,90,90,NA,7 159 | 4,291,2,62,1,2,70,60,475,27 160 | 12,179,2,63,1,1,80,70,538,-2 161 | 1,376,1,56,2,1,80,90,825,17 162 | 32,384,1,62,2,0,90,90,588,8 163 | 10,268,2,44,2,1,90,100,2450,2 164 | 11,292,1,69,1,2,60,70,2450,36 165 | 6,142,2,63,1,1,90,80,875,2 166 | 7,413,1,64,1,1,80,70,413,16 167 | 16,266,1,57,2,0,90,90,1075,3 168 | 11,194,2,60,2,1,80,60,NA,33 169 | 21,320,2,46,1,0,100,100,860,4 170 | 6,181,2,61,1,1,90,90,730,0 171 | 12,285,2,65,1,0,100,90,1025,0 172 | 13,301,1,61,1,1,90,100,825,2 173 | 2,348,2,58,2,0,90,80,1225,10 174 | 2,197,2,56,1,1,90,60,768,37 175 | 16,382,1,43,2,0,100,90,338,6 176 | 1,303,1,53,1,1,90,80,1225,12 177 | 13,296,1,59,2,1,80,100,1025,0 178 | 1,180,2,56,1,2,60,80,1225,-2 179 | 13,186,2,55,2,1,80,70,NA,NA 180 | 1,145,2,53,2,1,80,90,588,13 181 | 7,269,1,74,2,0,100,100,588,0 182 | 13,300,1,60,1,0,100,100,975,5 183 | 1,284,1,39,1,0,100,90,1225,-5 184 | 16,350,2,66,2,0,90,100,1025,NA 185 | 32,272,1,65,2,1,80,90,NA,-1 186 | 12,292,1,51,2,0,90,80,1225,0 187 | 12,332,1,45,2,0,90,100,975,5 188 | 2,285,2,72,2,2,70,90,463,20 189 | 3,259,1,58,1,0,90,80,1300,8 190 | 15,110,2,64,1,1,80,60,1025,12 191 | 22,286,2,53,1,0,90,90,1225,8 192 | 16,270,2,72,1,1,80,90,488,14 193 | 16,81,2,52,1,2,60,70,1075,NA 194 | 12,131,2,50,1,1,90,80,513,NA 195 | 1,225,1,64,1,1,90,80,825,33 196 | 22,269,2,71,1,1,90,90,1300,-2 197 | 12,225,1,70,1,0,100,100,1175,6 198 | 32,243,1,63,2,1,80,90,825,0 199 | 21,279,1,64,1,1,90,90,NA,4 200 | 1,276,1,52,2,0,100,80,975,0 201 | 32,135,2,60,1,1,90,70,1275,0 202 | 15,79,2,64,2,1,90,90,488,37 203 | 22,59,2,73,1,1,60,60,2200,5 204 | 32,240,1,63,2,0,90,100,1025,0 205 | 3,202,1,50,2,0,100,100,635,1 206 | 26,235,1,63,2,0,100,90,413,0 207 | 33,105,2,62,1,2,NA,70,NA,NA 208 | 5,224,1,55,2,0,80,90,NA,23 209 | 13,239,2,50,2,2,60,60,1025,-3 210 | 21,237,1,69,1,1,80,70,NA,NA 211 | 33,173,1,59,2,1,90,80,NA,10 212 | 1,252,1,60,2,0,100,90,488,-2 213 | 6,221,1,67,1,1,80,70,413,23 214 | 15,185,1,69,1,1,90,70,1075,0 215 | 11,92,1,64,2,2,70,100,NA,31 216 | 11,13,2,65,1,1,80,90,NA,10 217 | 11,222,1,65,1,1,90,70,1025,18 218 | 13,192,1,41,2,1,90,80,NA,-10 219 | 21,183,2,76,1,2,80,60,825,7 220 | 11,211,1,70,2,2,70,30,131,3 221 | 2,175,1,57,2,0,80,80,725,11 222 | 22,197,1,67,1,1,80,90,1500,2 223 | 11,203,1,71,2,1,80,90,1025,0 224 | 1,116,2,76,1,1,80,80,NA,0 225 | 1,188,1,77,1,1,80,60,NA,3 226 | 13,191,1,39,1,0,90,90,2350,-5 227 | 32,105,1,75,2,2,60,70,1025,5 228 | 6,174,1,66,1,1,90,100,1075,1 229 | 22,177,1,58,2,1,80,90,1060,0 230 | -------------------------------------------------------------------------------- /docs/files/chapter10/mtcars.csv: -------------------------------------------------------------------------------- 1 | mpg,cyl,disp,hp,drat,wt,qsec,vs,am,gear,carb 2 | 21,6,160,110,3.9,2.62,16.46,0,1,4,4 3 | 21,6,160,110,3.9,2.875,17.02,0,1,4,4 4 | 22.8,4,108,93,3.85,2.32,18.61,1,1,4,1 5 | 21.4,6,258,110,3.08,3.215,19.44,1,0,3,1 6 | 18.7,8,360,175,3.15,3.44,17.02,0,0,3,2 7 | 18.1,6,225,105,2.76,3.46,20.22,1,0,3,1 8 | 14.3,8,360,245,3.21,3.57,15.84,0,0,3,4 9 | 24.4,4,146.7,62,3.69,3.19,20,1,0,4,2 10 | 22.8,4,140.8,95,3.92,3.15,22.9,1,0,4,2 11 | 19.2,6,167.6,123,3.92,3.44,18.3,1,0,4,4 12 | 17.8,6,167.6,123,3.92,3.44,18.9,1,0,4,4 13 | 16.4,8,275.8,180,3.07,4.07,17.4,0,0,3,3 14 | 17.3,8,275.8,180,3.07,3.73,17.6,0,0,3,3 15 | 15.2,8,275.8,180,3.07,3.78,18,0,0,3,3 16 | 10.4,8,472,205,2.93,5.25,17.98,0,0,3,4 17 | 10.4,8,460,215,3,5.424,17.82,0,0,3,4 18 | 14.7,8,440,230,3.23,5.345,17.42,0,0,3,4 19 | 32.4,4,78.7,66,4.08,2.2,19.47,1,1,4,1 20 | 30.4,4,75.7,52,4.93,1.615,18.52,1,1,4,2 21 | 33.9,4,71.1,65,4.22,1.835,19.9,1,1,4,1 22 | 21.5,4,120.1,97,3.7,2.465,20.01,1,0,3,1 23 | 15.5,8,318,150,2.76,3.52,16.87,0,0,3,2 24 | 15.2,8,304,150,3.15,3.435,17.3,0,0,3,2 25 | 13.3,8,350,245,3.73,3.84,15.41,0,0,3,4 26 | 19.2,8,400,175,3.08,3.845,17.05,0,0,3,2 27 | 27.3,4,79,66,4.08,1.935,18.9,1,1,4,1 28 | 26,4,120.3,91,4.43,2.14,16.7,0,1,5,2 29 | 30.4,4,95.1,113,3.77,1.513,16.9,1,1,5,2 30 | 15.8,8,351,264,4.22,3.17,14.5,0,1,5,4 31 | 19.7,6,145,175,3.62,2.77,15.5,0,1,5,6 32 | 15,8,301,335,3.54,3.57,14.6,0,1,5,8 33 | 21.4,4,121,109,4.11,2.78,18.6,1,1,4,2 34 | -------------------------------------------------------------------------------- /docs/files/chapter10/records.csv: -------------------------------------------------------------------------------- 1 | 姓名,年龄,班级 2 | 周某某,9,3班 3 | 王某某,10,6班 -------------------------------------------------------------------------------- /docs/files/chapter10/records.tsv: -------------------------------------------------------------------------------- 1 | 姓名 年龄 班级 2 | 周某某 9 3班 3 | 王某某 10 6班 -------------------------------------------------------------------------------- /docs/files/chapter10/records.txt: -------------------------------------------------------------------------------- 1 | 姓名 年龄 班级 2 | 周某某 9 3班 3 | 王某某 10 6班 -------------------------------------------------------------------------------- /docs/files/chapter10/test1.csv: -------------------------------------------------------------------------------- 1 | 姓名,年龄,班级 2 | 周某某,9,3班 3 | 王某某,10,6班 4 | -------------------------------------------------------------------------------- /docs/files/chapter10/test2.csv: -------------------------------------------------------------------------------- 1 | ,姓名,年龄,班级 2 | 0,周某某,9,3班 3 | 1,王某某,10,6班 4 | -------------------------------------------------------------------------------- /docs/get_code.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | mkdir -p code 4 | 5 | for i in `ls *.md | xargs -n 1 | grep "[01][0-9]"` 6 | do 7 | echo 8 | echo "File $i" 9 | echo 10 | sed -n '/```/,/```/ p' < $i > "code/"$(echo $i | sed 's/.md//')".txt" 11 | echo "==========" 12 | done 13 | 14 | 15 | ## get rid of ``` 16 | ## sed -n '/^```/,/^```/p' < input.file | sed '/^```/d' -------------------------------------------------------------------------------- /docs/get_code_py.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | mkdir -p code_py 4 | 5 | for i in `ls *.md | xargs -n 1 | grep "[01][0-9]"` 6 | do 7 | echo 8 | echo "File $i" 9 | echo 10 | sed -n '/```python/,/```/ p' < $i | sed '/```/d' | sed 's/Out/# Out/' > "code_py/"$(echo $i | sed 's/.md//')".py" 11 | echo "==========" 12 | done 13 | 14 | 15 | ## Clean one by one 16 | ## ((In)|(Out)) ?\[[0-9]+\]: ? 17 | ## In ?\[[0-9]+\]: ? -------------------------------------------------------------------------------- /docs/get_fig_header.sh: -------------------------------------------------------------------------------- 1 | for i in `ls *.md | xargs -n 1 | grep "[01][0-9]"` 2 | do 3 | echo 4 | echo "File $i" 5 | echo 6 | sed -n '/!\[图.*\]/p' $i 7 | echo "==========" 8 | done -------------------------------------------------------------------------------- /docs/images/chapter1/Online_jupyter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/Online_jupyter.png -------------------------------------------------------------------------------- /docs/images/chapter1/Online_jupyter_Miscrosoft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/Online_jupyter_Miscrosoft.png -------------------------------------------------------------------------------- /docs/images/chapter1/download_anaconda_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/download_anaconda_0.png -------------------------------------------------------------------------------- /docs/images/chapter1/download_anaconda_win.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/download_anaconda_win.png -------------------------------------------------------------------------------- /docs/images/chapter1/download_nteract_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/download_nteract_0.png -------------------------------------------------------------------------------- /docs/images/chapter1/download_nteract_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/download_nteract_1.png -------------------------------------------------------------------------------- /docs/images/chapter1/install_anaconda_win_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/install_anaconda_win_1.png -------------------------------------------------------------------------------- /docs/images/chapter1/install_anaconda_win_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/install_anaconda_win_2.png -------------------------------------------------------------------------------- /docs/images/chapter1/install_anaconda_win_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/install_anaconda_win_3.png -------------------------------------------------------------------------------- /docs/images/chapter1/install_anaconda_win_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/install_anaconda_win_4.png -------------------------------------------------------------------------------- /docs/images/chapter1/install_anaconda_win_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/install_anaconda_win_5.png -------------------------------------------------------------------------------- /docs/images/chapter1/install_anaconda_win_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/install_anaconda_win_6.png -------------------------------------------------------------------------------- /docs/images/chapter1/install_anaconda_win_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/install_anaconda_win_7.png -------------------------------------------------------------------------------- /docs/images/chapter1/install_anaconda_win_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/install_anaconda_win_8.png -------------------------------------------------------------------------------- /docs/images/chapter1/install_notes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/install_notes.png -------------------------------------------------------------------------------- /docs/images/chapter1/install_nteract_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/install_nteract_0.png -------------------------------------------------------------------------------- /docs/images/chapter1/install_nteract_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/install_nteract_1.png -------------------------------------------------------------------------------- /docs/images/chapter1/nb_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/nb_home.png -------------------------------------------------------------------------------- /docs/images/chapter1/nteract_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/nteract_1.png -------------------------------------------------------------------------------- /docs/images/chapter1/nteract_web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/nteract_web.png -------------------------------------------------------------------------------- /docs/images/chapter1/use_anaconda_win_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/use_anaconda_win_1.png -------------------------------------------------------------------------------- /docs/images/chapter1/use_anaconda_win_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/use_anaconda_win_2.png -------------------------------------------------------------------------------- /docs/images/chapter1/use_anaconda_win_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/use_anaconda_win_3.png -------------------------------------------------------------------------------- /docs/images/chapter1/use_anaconda_win_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/use_anaconda_win_4.png -------------------------------------------------------------------------------- /docs/images/chapter1/use_anaconda_win_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/use_anaconda_win_5.png -------------------------------------------------------------------------------- /docs/images/chapter1/use_anaconda_win_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/use_anaconda_win_6.png -------------------------------------------------------------------------------- /docs/images/chapter1/use_anaconda_win_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/use_anaconda_win_7.png -------------------------------------------------------------------------------- /docs/images/chapter1/use_nteract_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter1/use_nteract_0.png -------------------------------------------------------------------------------- /docs/images/chapter10/hdf5_time_series.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter10/hdf5_time_series.png -------------------------------------------------------------------------------- /docs/images/chapter12/numpy_pandas_comparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter12/numpy_pandas_comparison.png -------------------------------------------------------------------------------- /docs/images/chapter2/nteract_My_bmi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter2/nteract_My_bmi.png -------------------------------------------------------------------------------- /docs/images/chapter2/nteract_cell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter2/nteract_cell.png -------------------------------------------------------------------------------- /docs/images/chapter2/nteract_hello_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter2/nteract_hello_world.png -------------------------------------------------------------------------------- /docs/images/chapter2/nteract_hello_world_wrong.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter2/nteract_hello_world_wrong.png -------------------------------------------------------------------------------- /docs/images/chapter2/nteract_save.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter2/nteract_save.jpg -------------------------------------------------------------------------------- /docs/images/chapter2/nteract_sg_calc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter2/nteract_sg_calc.png -------------------------------------------------------------------------------- /docs/images/chapter2/nteract_sg_calc2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter2/nteract_sg_calc2.png -------------------------------------------------------------------------------- /docs/images/chapter5/mnlisha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter5/mnlisha.png -------------------------------------------------------------------------------- /docs/images/chapter7/Figure_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/images/chapter7/Figure_1.png -------------------------------------------------------------------------------- /docs/interactive_python.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/interactive_python.docx -------------------------------------------------------------------------------- /docs/merge_book.sh: -------------------------------------------------------------------------------- 1 | ls *.md | xargs -n 1 | grep "[01]" > tmp_list 2 | Rscript swap_line.R 1 2 tmp_list 3 | cat `cat tmp_list` > interactive_python.md 4 | rm tmp_list 5 | -------------------------------------------------------------------------------- /docs/rm_space.sh: -------------------------------------------------------------------------------- 1 | sed -i 's/ *$//' *.md -------------------------------------------------------------------------------- /docs/swap_line.R: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env Rscript 2 | args = commandArgs(trailingOnly = TRUE) 3 | l1 = as.integer(args[1]) 4 | l2 = as.integer(args[2]) 5 | file = args[3] 6 | dt = data.table::fread(file, header = FALSE) 7 | 8 | swap <- function(x,i,j) {x[c(i,j)] <- x[c(j,i)]; x} 9 | data.table::fwrite(dt[swap(1:nrow(dt), l1, l2)], file = file, quote = FALSE, row.names = FALSE, col.names = FALSE) 10 | -------------------------------------------------------------------------------- /docs/to-readers.md: -------------------------------------------------------------------------------- 1 | # 对读者说的话 2 | 3 | 作为 21 世纪最性感的职业,数据科学家的背后需要超乎常人的付出,他要构建业务逻辑思维、修炼数理统计内功、打造编程利器,然后不断实践和更新技能。我在本书中以粗浅的内容尝试引导各位初学者去接触、了解、学习和掌握这个职业中一些基础的概念和技能。在学习本书内容之后,我希望各位读者不要畏惧接下来迎门而上的挑战,能够敢于和勇于在自己实际的工作场景中思考和应用所学,不断地学习和进阶。在遇到困难时,读者应当常常通过搜索引擎动手查找和解决问题,还可以通过一些专业问答社区和论坛与他人进行交流讨论。学习之路是快乐的,也是痛苦的,祝愿各位读者能在这个性感的职业中尽用所学,并乐在其中。 4 | 5 | -------------------------------------------------------------------------------- /docs/人邮社出版流程等参考文档/01出版流程.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/人邮社出版流程等参考文档/01出版流程.docx -------------------------------------------------------------------------------- /docs/人邮社出版流程等参考文档/02原创图书写作注意事项及说明.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/人邮社出版流程等参考文档/02原创图书写作注意事项及说明.docx -------------------------------------------------------------------------------- /docs/人邮社出版流程等参考文档/04参考目录.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/人邮社出版流程等参考文档/04参考目录.doc -------------------------------------------------------------------------------- /docs/人邮社出版流程等参考文档/05参考样章.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/人邮社出版流程等参考文档/05参考样章.doc -------------------------------------------------------------------------------- /docs/人邮社出版流程等参考文档/06参考程序样式.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/人邮社出版流程等参考文档/06参考程序样式.docx -------------------------------------------------------------------------------- /docs/人邮社出版流程等参考文档/07参考内容提要.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/人邮社出版流程等参考文档/07参考内容提要.docx -------------------------------------------------------------------------------- /docs/人邮社出版流程等参考文档/08参考前言.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShixiangWang/pybook/f82ee86cd2a0c3a45533e05de0a8d2c2a70a3545/docs/人邮社出版流程等参考文档/08参考前言.doc -------------------------------------------------------------------------------- /docs/大纲.md: -------------------------------------------------------------------------------- 1 | # 大纲 2 | 3 | - 中文名:《交互的Python:数据分析入门》 4 | - 英文名:《Interactive Python: An Introduction to Data Science》 5 | 6 | ## 面向读者 7 | 8 | 本书主要面向的是**没有编程基础和数据处理分析经验的读者**,也可以作为数据分析相关方向职业技术人员/学生作为参考和学习使用。 9 | 10 | ## 本书目的与特点 11 | 12 | 已有的编程书籍常常堆积着枯燥乏味的术语,而且大都不针对数据分析领域。另外,**当前各类编程语言的模式基本都是“编辑-编译-运行”,这非常适用于编写功能明确的代码,像各类游戏、网站等;而数据分析重“探索”,旨在在理解数据的基础上加以利用,具有极强的交互性,需要不断地尝试各种代码进行分析,根据对分析结果的理解寻找数据背后隐藏的模式,因此更需要一种“运行-探索”的新工作模式。在内容的讲解上,数据分析书籍应强调探索,注重思考,而非简单概念的梳理和代码实现。遗憾的是,市面上大多数书籍都属于后者,对于数据分析人员仅能做参考而非学习使用。**正是根据这一理解,本书的内容从头到尾都在阐述对概念与问题的思考、探索与解决,一些概念的讲述只是为这一核心提供理论基础。如果说理论知识是硬件,那么理论知识实现的探索分析就是软件,本书正是为需要它的读者提供软硬件支持。 13 | 14 | ## 本书内容大纲 15 | 16 | 本书内容主要涉及3个方面,一是Python的基础知识,这部分是任何使用Python工作的人都必须学习和掌握的;二是数据分析核心模块的学习和使用,这部分是任何使用Python进行数据处理工作都应当学习的;三是扩展内容,这里包括Markdown,一种流行的文本书写语言,但我把它放在前面章节讲解,因为个人认为书写文档对于数据分析从业者来说与代码探索、实现同等重要,有必要掌握Markdown这一门简单高效的工具。另外是一些Python中比较高级的用法(不常用),在数据分析时也极少用到,包括面向对象编程、异常处理等,对于想要入门分析的读者来说只是增加障碍,在读者学会基础后再学习和利用这一些比较高级的理论方法更为妥当。 17 | 18 | 在内容的撰写上,例子和代码中英文参杂。考虑读者本身的工作语境是中文,所以本书不少实例都使用了中文,以便于读者更好地理解和与工作对接。但英文的学习是有必要的,当前Python并没有官方中文文档,另外,在实际工作时遇到的大多数问题都要学习和利用英文搜索和提问等。 19 | 20 | 本书的学习平台是Anaconda,该平台几乎集成了常用的Python计算包,读者将更多地可以将精力放在学习、及时将所学应用于工作环境而非在与学习无关的软件安装、脚本运行等各种问题中浪费时间。 21 | 22 | * 0-前言-本书介绍 23 | * 1-介绍与准备工作 24 | * 2-python基础 25 | * 3-基本数据结构 26 | * 4-控制流与文件操作 27 | * 5-函数和模块 28 | * 6-Numpy 29 | * 7-Matplotlib 30 | * 8-Pandas入门 31 | * 9-Markdown基础 32 | * 10-数据导入 33 | * 11-数据分析工具箱 34 | * 12-Pandas进阶 35 | * 13-数据可视化进阶 36 | * 14-统计分析 37 | * 15-拓展-未言及的内容 38 | * 16-结语-接下来学什么 39 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: 交互的Python:数据分析入门 2 | docs_dir: "docs" 3 | site_dir: "site" 4 | theme: 5 | name: material 6 | features: 7 | - navigation.instant 8 | - navigation.tracking 9 | - navigation.tabs 10 | - navigation.expand 11 | - navigation.indexes 12 | - navigation.top 13 | repo_url: https://github.com/ShixiangWang/pybook 14 | edit_uri: https://github.com/ShixiangWang/pybook/edit/master/ 15 | site_author: Shixiang Wang 16 | copyright: Copyright © 2020 ShixiangWang 17 | nav: 18 | - 阅读说明: README.md 19 | - 正文: 20 | - 大纲.md 21 | - 0-前言.md 22 | - 00-内容提要.md 23 | - 01-introduction.md 24 | - 02-base.md 25 | - 03-data-structure.md 26 | - 04-control-flow.md 27 | - 05-function-and-module.md 28 | - 06-numpy.md 29 | - 07-matplotlib.md 30 | - 08-pandas-intro.md 31 | - 09-markdown.md 32 | - 10-data-import.md 33 | - 11-toolbox.md 34 | - 12-advanced-pandas.md 35 | - 13-advanced-vis.md 36 | - 14-stats.md 37 | - 15-append.md 38 | - 16-end.md 39 | - 思维导图: author-and-recommendation/交互的Python - 思维导图.png 40 | - 对读者说的话: to-readers.md 41 | - 作者简介: author.md 42 | markdown_extensions: 43 | - smarty 44 | - toc: 45 | permalink: True 46 | separator: "-" 47 | toc_depth: 3 --------------------------------------------------------------------------------