关于我们
书单推荐
新书推荐
|
Python数据分析与可视化应用 读者对象:本书适合作为高等学校计算机科学与技术、人工智能、大数据等相关专业Python 课程的教材,也适合对Python 感兴趣或拟使用Python 进行数据分析和可视化展示的读者参考。
本书结合作者多年工程和实践经验,从Python 基础编程语法入手,系统介绍了基于Python 语言进行数据处理、分析与可视化展示所需的各项知识和技术。读者无须特别的数学或统计方面的理论知识,只需理解数据分析的思路,就可以参考示例学会针对实际问题进行有效数据分析的步骤和方法。 本书分4 篇共20 章,主要内容涉及Python 基本语法、程序控制结构、函数、面向对象基础、文件操作、标准库、正则表达式、numpy 库、pandas 库、数据预处理、matplotlib 可视化图表、seaborn可视化图表、pyecharts 可视化图表、SciPy 科学计算、共享自行车案例及在线销售案例。
唐艺,助理研究员,长期从事计算机应用、信息系统的教学与科研工作,作为课题负责人申报省部级课题10余项。
第一篇 Python 基础
第1 章 Python 概述 ······················.2 1.1 Python 简介 ······························.2 1.1.1 Python 的起源 ··················.2 1.1.2 Python 的发展 ··················.2 1.2 Python 解释器 ···························.3 1.2.1 安装Python 解释器 ···········.3 1.2.2 交互运行模式 ··················.4 1.2.3 命令行运行模式 ···············.4 1.3 集成开发环境PyCharm ················.5 1.3.1 安装PyCharm ··················.5 1.3.2 创建项目 ························.7 1.3.3 创建并运行Python 文件 ·····.8 第2 章 Python 编程基础 ················10 2.1 常量和变量 ·······························10 2.1.1 常量和变量的定义 ············10 2.1.2 变量命名规则 ··················10 2.2 简单数据类型 ···························.11 2.2.1 数值类型 ·······················.11 2.2.2 字符串 ···························12 2.2.3 None ·····························13 2.2.4 布尔类型 ························14 2.2.5 数据类型转换 ··················14 2.3 算术运算 ··································15 2.4 赋值运算符 ·······························16 2.5 字符串相关运算 ·························17 2.5.1 字符串连接运算 ···············17 2.5.2 字符串截取 ·····················18 2.6 输出 ········································18 2.6.1 print 函数的基本用法 ········19 2.6.2 print 函数格式化输出 ········20 2.7 输入 ········································23 2.8 程序注释 ··································23 第3 章 程序控制结构 ····················25 3.1 选择结构 ··································25 3.1.1 条件表达式 ·····················25 3.1.2 单分支结构if 语句············27 3.1.3 二分支结构if-else 语句 ······27 3.1.4 多分支结构if-elif-else语句 ······························29 3.2 循环结构 ··································31 3.2.1 for 语句实现遍历循环 ········31 3.2.2 while 语句实现条件循环 ····33 3.2.3 循环结构中的else 语句 ······35 3.2.4 break 语句和continue语句 ······························36 第4 章 组合数据类型 ····················39 4.1 列表 ········································39 4.1.1 列表的表示与访问列表元素 ······························39 4.1.2 遍历列表 ························40 4.1.3 添加列表元素 ··················42 4.1.4 删除列表元素 ··················44 4.1.5 列表排序 ························45 4.2 元组 ········································46 4.3 字典 ········································47 4.3.1 创建字典 ························48 4.3.2 添加和删除键值对 ············49 4.3.4 遍历字典 ························49 4.3.5 字典嵌套 ························50 第5 章 函数 ································52 5.1 函数的定义和调用 ······················52 5.2 函数参数传递 ····························54 5.3 列表作为函数参数 ······················57 5.3.1 简单数据类型参数传递值 ···························57 5.3.2 组合数据类型参数公用存储空间 ··················57 5.3.3 组合数据类型的数据作为函数参数的应用 ·········58 5.4 模块 ········································59 5.4.1 创建模块 ························59 5.4.2 导入模块 ························60 第6 章 类和对象 ··························63 6.1 类和对象的概念 ·························63 6.2 定义只具有方法的类和对象 ··········64 6.2.1 定义类 ···························64 6.2.2 实例化对象 ·····················65 6.3 对象初始化方法及属性 ················66 6.3.1 对象初始化方法_ _init_ _() ······················66 6.3.2 定义类的属性 ··················66 6.3.3 访问对象属性 ··················67 6.3.4 输出对象的描述信息 ·········68 6.3.5 封装性 ···························69 6.4 类和对象应用实例 ······················69 6.5 类的继承 ··································70 6.5.1 继承的定义 ·····················70 6.5.2 _init_ _() 方法的继承 ·······72 6.5.3 重写父类方法 ··················73 第7 章 文件操作 ··························74 7.1 基本操作 ··································74 7.2 打开文件 ··································75 7.2.1 文件指针 ························75 7.2.2 打开方式 ························76 7.3 读取文件 ··································77 7.4 写入文件 ··································78 7.4.1 使用write() 方法向文件中写入内容 ························78 7.4.2 使用write() 方法向文件中追加内容 ························79 7.5 读写CSV 文件 ··························80 7.5.1 读取数据 ························80 7.5.2 写入数据 ························81 第8 章 常用Python 标准库 ············83 8.1 datetime 模块 ·····························83 8.1.1 date 类 ···························83 8.1.2 time 类 ···························86 8.1.3 datetime 类 ······················86 8.1.4 timedelta 类 ·····················87 8.1.5 时间转化 ························88 8.1.6 设置日期时间格式 ············88 8.2 math 模块 ·································89 8.3 random 模块 ······························90 8.4 os 模块 ····································92 第二篇 数 据 分 析 第9 章 正则表达式 ·······················98 9.1 正则表达式中的元字符 ················98 9.1.1 主要元字符 ·····················98 9.1.2 对字符进行转义 ···············99 9.1.3 标记开始与结束 ···············99 9.2 匹配一组字符 ·························.100 9.2.1 定义一组字符 ···············.100 9.2.2 对一组字符取反 ············.100 9.2.3 使用区间简化一组字符的定义 ···························.100 9.3 使用量词进行多次匹配 ·············.101 9.3.1 常用量词 ·····················.101 9.3.2 贪婪和非贪婪匹配 ·········.101 9.3.3 分组 ···························.102 9.4 使用re 模块处理正则表达式 ······.102 9.4.1 Python 正则表达式的语法 ···························.102 9.4.2 匹配字符串 ··················.102 9.4.3 替换字符串 ··················.106 9.4.4 分割字符串 ··················.107 第10 章 使用numpy 进行数值计算 ·····························108 10.1 使用numpy 生成数组 ·············.108 10.1.1 常用数组生成函数 ·······.108 10.1.2 ndarray 对象属性 ·········.109 10.1.3 数组变换 ·····················110 10.1.4 numpy 的随机数函数 ······112 10.2 数组的索引和切片 ···················112 10.2.1 数组的索引 ··················112 10.2.2 数组的切片 ··················113 10.3 数组的运算 ····························114 10.3.1 数组和标量间的运算 ······114 10.3.2 通用函数 ·····················114 10.3.3 统计运算 ·····················115 10.4 数组的存储与读取 ···················116 10.4.1 数组的存储 ··················116 10.4.2 数组的读取 ··················116 第11 章 pandas 数据分析模块 ·····.118 11.1 pandas 数据结构 ······················118 11.1.1 创建Series 数据 ·············118 11.1.2 创建DataFrame 数据 ·····.120 11.2 添加、修改和删除数据 ···········.121 11.2.1 添加数据 ···················.122 11.2.2 修改数据 ···················.123 11.2.3 删除数据 ···················.124 11.3 索引操作 ·····························.126 11.3.1 重设索引 ···················.126 11.3.2 将已有列设置为索引 ····.126 11.3.3 重新命名索引 ·············.127 11.3.4 层次化索引 ················.128 11.4 选取数据 ·····························.130 11.4.1 Series 数据的选取 ········.130 11.4.2 DataFrame 数据的选取 ·························.131 11.5 数据运算 ·····························.133 11.5.1 算术运算 ···················.133 11.5.2 函数应用和映射 ··········.134 11.5.3 汇总与统计 ················.135 11.5.4 唯一值和值计数 ··········.138 第12 章 使用pandas 获取和写入数据 ·····························140 12.1 文本数据的读取与存储 ···········.140 12.1.1 CSV 文件的读取 ··········.140 12.1.2 TXT 文件的读取 ··········.142 12.1.3 文本数据的存储 ··········.143 12.2 Excel 与JSON 数据 ················.143 12.2.1 Excel 数据 ··················.143 12.2.2 JSON 数据 ·················.144 12.3 数据库的读取与写入 ··············.145 12.3.1 SQLAlchemy 包的安装和数据库的链接 ·············.145 12.3.2 SQLite 数据库写入和读取数据 ·························.145 第13 章 数据预处理 ····················147 13.1 数据清洗 ·····························.147 13.1.1 处理缺失值 ················.147 13.1.2 删除重复数据 ·············.150 13.1.3 替换值 ······················.151 13.1.4 利用函数或映射进行数据转换 ···················.152 13.2 对数据进行排序和排名 ···········.153 13.2.1 数据排序 ···················.153 13.2.2 数据排名 ···················.155 13.3 数据合并和重塑 ····················.156 13.3.1 数据合并 ···················.156 13.3.2 数据连接 ···················.157 13.3.3 数据转置 ···················.159 13.4 字符串处理 ··························.159 13.4.1 字符串方法 ················.159 13.4.2 使用正则表达式 ··········.160 14.1 数据分组 ·····························.161 14.1.1 认识GroupBy ·············.161 第14 章 数据的分组与聚合 ···········161 14.1.2 按照列名进行分组 ·······.162 14.1.3 按照Series 数据进行 分组 ·························.163 14.2 数据聚合 ·····························.164 14.2.1 聚合函数 ···················.164 14.2.2 使用aggregate() 方法 进行数据聚合 ·············.165 14.3 长表变宽表 ··························.166 14.3.1 什么是长表和宽表 ·······.166 14.3.2 使用pivot 函数将长表变为宽表 ···················.167 14.3.3 使用pivot_table 函数进行数据透视分析 ·······.167 第三篇 数据可视化 第15 章 使用matplotlib 可视化数据 170 15.1 创建图表的基本方法 ··············.170 15.1.1 图表的基本组成元素 ····.170 15.1.2 建立画布和坐标系 ·······.171 15.1.3 设置坐标轴 ················.175 15.1.4 设置网格线 ················.177 15.1.5 设置图例 ···················.178 15.1.6 设置图表标题 ·············.179 15.1.7 设置数据标签 ·············.180 15.1.8 设置数据表 ················.181 15.1.9 绘制常用几何图形 ·······.182 15.2 常用图表的创建 ····················.186 15.2.1 折线图 ······················.186 15.2.2 柱形图 ······················.188 15.2.3 饼图和圆环图 ·············.191 15.2.4 散点图和气泡图 ··········.191 15.2.5 直方图 ······················.193 15.2.6 箱形图 ······················.194 15.2.7 等高线图 ···················.196 15.2.8 阶梯图 ······················.196 第16 章 使用seaborn 可视化数据 ·····························198 16.1 seaborn 的样式 ······················.198 16.1.1 基本样式 ···················.198 16.1.2 自定义样式 ················.199 16.2 绘制分布图 ··························.200 16.2.1 单变量分布图 ·············.200 16.2.2 多变量分布图 ·············.202 16.3 绘制分类图 ··························.204 16.3.1 分类散点图 ················.204 16.3.2 箱形图与琴形图 ··········.204 16.3.3 回归图 ······················.205 第17 章 使用pyecharts 动态可视化数据 ····················207 17.1 pyecharts 的版本与特点 ···········.207 17.2 pyechats 可视化的流程及选项设置 ···································.207 17.2.1 pyecharts 可视化的一般流程 ·························.207 17.2.2 pyecharts 选项设置 ·······.209 17.2.3 pyecharts 常用的图表设置方法 ·····················211 17.3 使用pyecharts 创建图表 ··········.214 17.3.1 饼图和圆环图 ·············.214 17.3.2 折线图和面积图 ··········.216 17.3.3 散点图和气泡图 ··········.218 17.3.4 直方图和箱形图 ··········.219 17.3.5 词云图 ······················.221 17.3.6 数据地图 ···················.222 17.3.7 雷达图 ······················.224 17.3.8 仪表盘和水球图 ··········.225 第18 章 使用SciPy 进行科学计算和统计分析 ··············227 18.1 使用SciPy 进行科学计算 ·········.227 18.1.1 获取基本科学常量 ·······.227 18.1.2 线性代数和微积分 ·······.228 18.1.3 插值与拟合 ················.229 18.2 使用SciPy 进行统计分析 ·········.230 18.2.1 正态分布有关计算 ·······.230 18.2.2 通过样本推断总体参数 ·························.231 18.2.3 检验均值 ···················.232 18.2.4 检验均值差 ················.233 18.2.5 卡方检验 ···················.234 18.2.6 回归分析 ···················.235 第四篇 实 例 应 用 第19 章 共享自行车大数据分析 ·····239 19.1 数据预处理 ··························.239 19.1.1 读取数据 ···················.239 19.1.2 数据清洗与转换 ··········.240 19.2 探索数据规律 ·······················.241 19.2.1 年份数据比较 ·············.241 19.2.2 月份趋势比较 ·············.241 19.2.3 每日高峰时段分析 ·······.243 19.2.4 不同季度差异分析 ·······.244 19.2.5 周末和工作日差异分析 ·························.245 第20 章 在线销售数据分析与建模 ··246 20.1 获取和清洗数据 ····················.246 20.1.1 获取数据 ···················.246 20.1.2 了解数据的基本特征 ····.247 20.1.3 清洗与整理数据 ··········.248 20.2 分析与可视化销售数据 ···········.249 20.2.1 查看销量的描述统计结果 ·························.249 20.2.2 按产品对销量进行汇总 ·························.249 20.2.3 按城市汇总产品 ··········.250 20.2.4 对产品和城市进行交叉分析 ·························.251 20.3 销量趋势分析 ·······················.251 20.3.1 日期格式转换 ·············.252 20.3.2 时间和季节趋势分析 ····.252 20.3.3 比较不同城市季节趋势的差异 ·························.253
你还可能感兴趣
我要评论
|