践行-在Python的路上很充实

数据分析
1 人赞同了该文章

本关重点理清9个学习要点:
一、为什么要学习Python?
Python很火、很热、很强大,我希望通过学习Python,能够具备数据分析能力,以概率思维武装头脑、以数据分析为抓手,理性地看待世界。
我特别羡慕社群里一些在读大学生,他们精力特别充沛、学习进度快,完成的课程作业也比较有深度。当然,社群里也有不少和我一样,始终受梦想牵引着,虽然学得很慢,但一直在匍匐前进的人。选择做自己认定是“对”的事情,这一点很重要。
二、如何安装Python?
我已经完成了Python的安装,Anaconda、jupyter notebook能正常使用;
煮酒:重启--Pythonzhuanlan.zhihu.com

三、快速学会Python的四个关键点--数据
1、注释
Python的注释有两种方法
#
''' '''

2、数据类型

2.1 数据类型:字符串和数值
输入的字符都要切换成英文格式,"+"可实现字符串相连。

2.2 数据类型:容器-列表 (List)
定义列表时,采用中括号 []

2.3 数据类型:容器-元祖(Tuple)
定义元祖时,采用小括号 ()

2.4 数据类型:容器-集合(Sets)
定义集合时,采用花括号{}


2.5 数据类型:容器-字典(Dictionary)
定义字典时,采用花括号{}


3、数据类型:布尔(True、False)
真和假,主要用在条件判断语句中,符合条件为True、不符合条件为False;

4、数据类型:None(空值)
是空值,是一个特殊值,它不能理解为0。
四、快速学会Python的四个关键点--函数
函数的功能、函数的输入、函数的输出
1、函数参数:不可变数据类型

<figcaption style="margin-top: 0.66667em; padding: 0px 1em; font-size: 0.9em; line-height: 1.5; text-align: center; color: rgb(153, 153, 153);">不可更改的对象,参数传递时,相当于传递的是复制出来的数据</figcaption>
字符串、数字、容器-元祖这3种属于不可更改的对象,如果函数参数是这3种中的一种,参数传递时,相当于传递的是复制出来的数据,对于数据本身没有影响。
2、函数参数:可变数据类型

如果参数传入的数据类型是可变的类型,当函数内部修改该数据时,原始的数据也改变了。
五、快速学会Python的四个关键点--条件判断
1、边界条件:
1)值比较: >、<、>=、<=、!=、==
2)逻辑比较: and、or、not


特别要注意,代码块中,要缩进,否则会报错;
六、快速学会Python的四个关键点--循环
批量处理数据,把容器中的每一个数据都按照特点的规则进行重复处理。

<figcaption style="margin-top: 0.66667em; padding: 0px 1em; font-size: 0.9em; line-height: 1.5; text-align: center; color: rgb(153, 153, 153);">例子中:if 与 print的缩进对齐关系非常严格,多一个空格,都会使print显示成红色,并执行出错。</figcaption>

<figcaption style="margin-top: 0.66667em; padding: 0px 1em; font-size: 0.9em; line-height: 1.5; text-align: center; color: rgb(153, 153, 153);">满足条件直接continue并循环(不执行print),不满足条件显示后再循环。</figcaption>

七、模块和包
1、按目录来组织模块的方法,称为包;包就是多个模块用文件夹的方式组织在一起;

2、jupyter notebook 导出成 .py 文件

3、模块使用的三种方式
import 包名称
import 包名称 as 别名
from 包名称 import 函数名 #只导入包中的函数
(例:from collections import deque )

八、数据结构
1、队列和栈


2、有序字典

<figcaption style="margin-top: 0.66667em; padding: 0px 1em; font-size: 0.9em; line-height: 1.5; text-align: center; color: rgb(153, 153, 153);">Key无序,Python默认的顺序</figcaption>

<figcaption style="margin-top: 0.66667em; padding: 0px 1em; font-size: 0.9em; line-height: 1.5; text-align: center; color: rgb(153, 153, 153);">Key有序,是按写入字典的顺序排列</figcaption>
3、计数器
Counter函数是以字符为单位进行分类统计。Excel中的countifs是以单元格为单位的分类统计。


九、如何学编程最有效?
既高效又有效的方法:多敲代码 和 使用搜索引擎。
十、小结
从Anaconda的环境安装、熟悉jupyter notebook使用界面、到学习数据类型、函数、条件判断、for循环、模块和包的导入等,以及贯穿始终的“多敲代码”。对Python有了初步了解,但这一关的学习花了三周时间。有收获,也还需要再用力“挤挤”,加油。
网友评论