All Projects → jackzhenguo → Python Small Examples

jackzhenguo / Python Small Examples

告别枯燥,致力于打造 Python 实用小例子,更多Python良心教程见 Python中文网 http://www.zglg.work

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Python Small Examples

Just Pandas Things
An ongoing list of pandas quirks
Stars: ✭ 660 (-89.98%)
Mutual labels:  data-science
Learn Julia The Hard Way
Learn Julia the hard way!
Stars: ✭ 679 (-89.69%)
Mutual labels:  data-science
Orchest
A new kind of IDE for Data Science.
Stars: ✭ 694 (-89.47%)
Mutual labels:  data-science
Ipython Dashboard
A stand alone, light-weight web server for building, sharing graphs created in ipython. Build for data science, data analysis guys. Aiming at building an interactive visualization, collaborated dashboard, and real-time streaming graph.
Stars: ✭ 664 (-89.92%)
Mutual labels:  data-science
Cracking The Data Science Interview
A Collection of Cheatsheets, Books, Questions, and Portfolio For DS/ML Interview Prep
Stars: ✭ 672 (-89.8%)
Mutual labels:  data-science
Featexp
Feature exploration for supervised learning
Stars: ✭ 688 (-89.56%)
Mutual labels:  data-science
Hyperparameter hunter
Easy hyperparameter optimization and automatic result saving across machine learning algorithms and libraries
Stars: ✭ 648 (-90.17%)
Mutual labels:  data-science
Statistical Rethinking With Python And Pymc3
Python/PyMC3 port of the examples in " Statistical Rethinking A Bayesian Course with Examples in R and Stan" by Richard McElreath
Stars: ✭ 713 (-89.18%)
Mutual labels:  data-science
Python Crfsuite
A python binding for crfsuite
Stars: ✭ 678 (-89.71%)
Mutual labels:  data-science
H1st
The AI Application Platform We All Need. Human AND Machine Intelligence. Based on experience building AI solutions at Panasonic: robotics predictive maintenance, cold-chain energy optimization, Gigafactory battery mfg, avionics, automotive cybersecurity, and more.
Stars: ✭ 697 (-89.42%)
Mutual labels:  data-science
Kaggle Cli
(Deprecated, use https://github.com/Kaggle/kaggle-api instead) An unofficial Kaggle command line tool.
Stars: ✭ 675 (-89.76%)
Mutual labels:  data-science
Roughviz
Reusable JavaScript library for creating sketchy/hand-drawn styled charts in the browser.
Stars: ✭ 6,022 (-8.61%)
Mutual labels:  data-science
Data Science Interview Resources
A repository listing out the potential sources which will help you in preparing for a Data Science/Machine Learning interview. New resources added frequently.
Stars: ✭ 690 (-89.53%)
Mutual labels:  data-science
Test Tube
Python library to easily log experiments and parallelize hyperparameter search for neural networks
Stars: ✭ 663 (-89.94%)
Mutual labels:  data-science
Cookbook 2nd
IPython Cookbook, Second Edition, by Cyrille Rossant, Packt Publishing 2018
Stars: ✭ 704 (-89.32%)
Mutual labels:  data-science
Deep Recommender System
深度学习在推荐系统中的应用及论文小结。
Stars: ✭ 657 (-90.03%)
Mutual labels:  data-science
Querido Diario
📰 Brazilian government gazettes, accessible to everyone.
Stars: ✭ 681 (-89.66%)
Mutual labels:  data-science
Industry Machine Learning
A curated list of applied machine learning and data science notebooks and libraries across different industries (by @firmai)
Stars: ✭ 6,077 (-7.77%)
Mutual labels:  data-science
Reflow
A language and runtime for distributed, incremental data processing in the cloud
Stars: ✭ 706 (-89.29%)
Mutual labels:  data-science
Sciblog support
Support content for my blog
Stars: ✭ 694 (-89.47%)
Mutual labels:  data-science

介绍

告别枯燥,告别枯燥,致力于打造 Python 经典小例子、小案例。

同时托管在Python中文网

使用Python制作的各种小工具:Python实用小工具

License

允许按照要求转载,但禁止用于任何商用目的。如果转载本库小例子、小案例,请备注下方链接:

Python小例子 https://github.com/jackzhenguo/python-small-examples

Python 小例子

基本操作

小例子 链接 标签 版本 难度
1 常见算术运算 运算 v1
2 实现 relu max V4.0 ⭐️⭐️
3 进制转化 bin,oct,hex V4.0 ⭐️⭐️
4 整数和ASCII互转 chr,ord V1.0 ⭐️⭐️
5 元素都为真检查 all V2.0 ⭐️⭐️⭐️
6 至少一个为真检查 any V2.0 ⭐️⭐️⭐️
7 判断是真是假 bool V2.0 ⭐️⭐️⭐️
8 创建复数 complex V1.0 ⭐️⭐️⭐️
9 取商和余数 divmod V1.0 ⭐️⭐️
10 转为浮点类型 float V1.0 ⭐️⭐️
11 转为整型 int V1.0 ⭐️
12 次幂 pow V1.0 ⭐️
13 四舍五入 round V1.0 ⭐️
14 链式比较 compare V1.0 ⭐️⭐️
15 字符串转字节 bytes,utf-8 V1.0 ⭐️⭐️
16 任意对象转为字符串 str V1.0 ⭐️⭐️
17 执行字符串表示的代码 compile V1.0 ⭐️⭐️⭐️
18 计算表达式 eval V1.0 ⭐️⭐️⭐️⭐️
19 字符串格式化 format V1.0 ⭐️⭐️⭐️⭐️
20 交换两元素 pack,unpack V1.0 ⭐️⭐️
21 转为字典 dict V1.0 ⭐️⭐️
22 冻结集合 frozenset V1.0 ⭐️⭐️
23 转为集合类型 set V1.0 ⭐️⭐️
24 转元组 tuple V1.0 ⭐️⭐️
25 查看变量所占字节数 getsizeof V1.0 ⭐️⭐️⭐️
26 含单个元素的元组 tuple V1.0 ⭐️
27 列表删除之坑 list V1.0 ⭐️
28 列表快速复制之坑 list V1.0 ⭐️
29 发现列表前3个最大或最小数 list heapq v1.0 ⭐️
30 字符串驻留 str V1.0 ⭐️
31 创建空集合错误 set V1.0 ⭐️
32 充分认识for for V1.0 ⭐️
33 认识执行时机 generator V1.0 ⭐️

函数和模块常见用法

小例子 链接 标签 版本 难度
1 操作函数对象 operator V2.0 ⭐️⭐️⭐️⭐️
2 创建range序列 range V1.0 ⭐️⭐️
3 生成逆序序列 range V1.0 ⭐️⭐️
4 拿来就用的排序函数 sorted V1.0 ⭐️⭐️⭐️
5 求和函数 sum V1.0 ⭐️⭐️
6 函数的五类参数使用例子 variable parameter V2.0 ⭐️⭐️⭐️⭐️
7 使用slice对象 slice V2.0 ⭐️⭐️⭐️⭐️⭐️
8 lambda 函数 lambda V3.0 ⭐️⭐️⭐️⭐️
9 枚举对象 enumerate V1.0 ⭐️⭐️⭐️
10 过滤器filter filter V1.5 ⭐️⭐️⭐️
11 返回对象哈希值 hash V1.0 ⭐️⭐️
12 带名字的元组 namedtuple V1.0 ⭐️⭐️⭐️
13 一行代码实现列表反转 reverse V1.0 ⭐️⭐️
14 反转字符串的两个方法 reversed V1.0 ⭐️⭐️
15 join 串联字符串 join V1.0 ⭐️⭐️
16 字符串字节长度 encode V1.0 ⭐️⭐️
17 groupby单字段分组 itertools, groupby,lambda V1.0 ⭐️⭐️⭐️
18 groupby多字段分组 itemgetter,itertools,groupby V1.0 ⭐️⭐️⭐️⭐️
19 itemgetter和key函数 operator,itemgetter,itertools V1.0 ⭐️⭐️⭐️⭐️⭐️
20 sum函数计算和聚合同时做 sum,generator V1.0 ⭐️⭐️⭐️⭐️⭐️
21 默认参数设为空 function V1.0 ⭐️
22 各种参数使用之坑 function paremeter V1.0 ⭐️
23 lambda自由参数之坑 lambda V1.0 ⭐️
24 使用堆升序列表 sort heapq v1.0 ⭐️

面向对象

小例子 链接 标签 版本 难度
1 所有对象之根 object V1.0 ⭐️
2 对象是否可调用 callable V2.5 ⭐️⭐️⭐️⭐️
3 ascii 展示对象 __repr__ V2.5 ⭐️⭐️⭐️
4 类方法 classmethod V1.5 ⭐️⭐️⭐️
5 动态删除属性 delattr,hasattr V1.5 ⭐️⭐️
6 一键查看对象所有方法 dir V1.5 ⭐️⭐️
7 动态获取对象属性 getattr V1.5 ⭐️⭐️
8 对象是否有某个属性 hasattr V1.5 ⭐️⭐️⭐️
9 对象门牌号 id V1.0 ⭐️
10 实例和对象关系判断 isinstance V1.5 ⭐️⭐️⭐️
11 issubclass父子关系鉴定 issubclass V1.5 ⭐️⭐️⭐️
12 创建属性的两种方法 property V2.5 ⭐️⭐️⭐️⭐️⭐️
13 查看对象类型 type V1.0 ⭐️
14 元类使用介绍 type,__class__ V2.0 ⭐️⭐️⭐️⭐️⭐️
15 相同值的不可变对象 mutable V1.0 ⭐️
16 对象销毁顺序 OOP del V1.0 ⭐️
17 子类继承父类的静态方法吗? staticmethod V1.0 ⭐️

正则

小例子 链接 标签 版本 难度
1 正则中字符 r作用 re,r V3.0 ⭐️⭐️⭐️
2 正则原子操作 re V3.0 ⭐️⭐️⭐️
3 正则中的转义 re,\ V3.0 ⭐️⭐️⭐️
4 正则最普通查找 re,findall V3.0 ⭐️⭐️⭐️
5 使用通用字符查找 re,\s,\w,\d V3.0 ⭐️⭐️⭐️
6 使用元字符查找 re,+,* V3.0 ⭐️⭐️⭐️
7 捕获子串 () V3.0 ⭐️⭐️⭐️⭐️
8 贪心捕获和非贪心捕获 re V1.0 ⭐️⭐️⭐️⭐️
9 使用正则做密码安全检查 re V1.0 ⭐️⭐️⭐️⭐️⭐️
10 爬取百度首页标题 re V1.0 ⭐️⭐️⭐️⭐️
11 批量转化为驼峰格式(Camel) re V1.0 ⭐️⭐️⭐️⭐️⭐️
12 使用正则判断是否为正浮点数 str,re,float V1.0 ⭐️⭐️⭐️⭐️⭐️
13 使用正则提取正整数和大于0的浮点数 re findall v2 ⭐️

装饰器迭代器生成器

小例子 链接 标签 版本 难度
1 通俗理解装饰器 decorator V1.0 ⭐️⭐️⭐️
2 测试函数运行时间的装饰器 decorator V1.0 ⭐️⭐️⭐️⭐️
3 统计异常次数装饰器 decorator,nonlocal V1.5 ⭐️⭐️⭐️⭐️
4 定制递减迭代器 Iterator V3.0 ⭐️⭐️⭐️⭐️
5 创建迭代器 iter,__iter__ V1.5 ⭐️⭐️⭐️
6 反向迭代器reversed reversed V1.0 ⭐️⭐️
7 zip迭代器 zip V1.5 ⭐️⭐️⭐️
8 list分组(生成器版) yield,generator V1.0 ⭐️⭐️⭐️
9 列表全展开(生成器版) list,yield,generator V1.0 ⭐️⭐️⭐️
10 chain串联小容器为大容器 itertools,chain V1.0 ⭐️⭐️⭐️⭐️⭐️
11 product 使用案例 product V1.0 ⭐️⭐️⭐️⭐️⭐️
12 斐波那契数列前n项 yield,range V1.0 ⭐️⭐️⭐️

绘图

小例子 链接 标签 版本 难度
1 turtle绘制奥运五环图 turtle V1.0 ⭐️⭐️⭐️
2 turtle绘制漫天雪花 turtle V1.0 ⭐️⭐️⭐️
3 Python词云图 WordCloud V1.0 ⭐️⭐️
4 Plotly柱状图和折线图 plotly V1.0 ⭐️
5 seaborn热力图 seaborn V1.0 ⭐️
6 Pyecharts仪表盘 pyecharts V1.0 ⭐️
7 Pyecharts漏斗图 pyecharts V1.0 ⭐️
8 Pyecharts水球图 pyecharts V1.0 ⭐️
9 Pyecharts饼图 pyecharts V1.0 ⭐️
10 Pyecharts极坐标图 pyecharts V1.0 ⭐️
11 Pyecharts词云图 pyecharts V1.0 ⭐️
12 Pyecharts热力图 pyecharts V1.0 ⭐️
13 matplotlib绘制动图 matplotlib V1.0 ⭐️
14 seaborn pairplot图 seaborn V1.0 ⭐️
15 pyecharts传入Numpy数据绘图失败 numpy pyecharts V1.0 ⭐️
16 图像处理包pillow pillow V1.0 ⭐️

数据分析

小例子 链接 标签 版本 难度
1 数据分析神器:deepnote deepnote v1.0 ⭐️
2 NumPy 的pad填充方法 NumPy pad V1.0 ⭐️
3 创建下对角线为1、2、3、4的对角矩阵 NumPy diag V1.0 ⭐️
4 cut 数据分箱 Pandas cut v1.0 ⭐️
5 丢弃空值和填充空值 Pandas dropna fillna v1.0 ⭐️
6 apply 方法去掉特殊字符 pandas apply v1.0 ⭐️
7 使用map对列做特征工程 pandas map v1.0 ⭐️
8 category列转数值 pandas category v1.0 ⭐️
9 rank排名 pandas rank v1.0 ⭐️
10 完成数据下采样,调整步长由小时为天 pandas resample v1.0 ⭐️
11 如何用 Pandas 快速生成时间序列数据 pandas util v1.0 ⭐️
12 如何快速找出 DataFrame 所有列 null 值个数 pandas isnull sum v1.0 ⭐️
13 重新排序 DataFrame 的列 pandas dataframe v1.0 ⭐️
14 使用 count 统计词条 出现次数 pandas count v1.0 ⭐️
15 split 求时分(HH:mm)的分钟差 pandas split v1.0 ⭐️
16 melt透视数据小技巧 pandas melt v1.0 ⭐️
17 pivot 透视小技巧 pandas melt v1.0 ⭐️
18 p随机读取文件的K行,生成N个 pandas sample v1.0 ⭐️
19 格式化Pandas的时间列 pandas apply v1.0 ⭐️

其他常用

小例子 链接 标签 版本 难度
1 help 一键帮助 help V1.0 ⭐️
2 获取用户输入 input V1.0 ⭐️
3 文件读写和mode 取值表 open,read,write,with,mode V2.0 ⭐️⭐️⭐️
4 operator使用举例 operator V1.0 ⭐️⭐️⭐️⭐️
5 传输json对象 json V2.0 ⭐️⭐️⭐️⭐️⭐️
6 获取文件后缀名 os,splitext V1.0 ⭐️⭐️
7 获取路径中的文件名 os,split V1.0 ⭐️⭐️
8 批量修改文件后缀 argparse,listdir V1.0 ⭐️⭐️⭐️⭐️
9 xls批量转换成xlsx os,listdir,splitext V1.0 ⭐️⭐️⭐️⭐️
10 获取指定后缀名的文件 os,listdir,splitext V1.0 ⭐️⭐️⭐️⭐️
11 批量压缩文件 zipfile V1.0 ⭐️⭐️⭐️⭐️
12 32位加密 hashlib V1.0 ⭐️⭐️⭐️⭐️
13 年的日历图 calendar V1.0 ⭐️⭐️
14 判断是否为闰年 calendar V1.0 ⭐️⭐️⭐️
15 判断月有几天 calendar,datetime V1.0 ⭐️⭐️⭐️
16 月的第一天 datetime V1.0 ⭐️⭐️
17 月的最后一天 calendar,datetime V1.0 ⭐️⭐️
18 获取当前时间 time,datetime V1.0 ⭐️⭐️
19 字符时间转时间 time,datetime V1.0 ⭐️⭐️
20 时间转字符时间 time,datetime V1.0 ⭐️⭐️
21 获得某天后的1~n天 Calendar,monthrange V4.0 ⭐️⭐️⭐️
22 默认启动主线程 threading V1.0 ⭐️⭐️
23 创建线程 threading V1.0 ⭐️⭐️
24 交替获得CPU时间片 threading V1.0 ⭐️⭐️⭐️
25 多线程抢夺同一个变量 threading V1.0 ⭐️⭐️⭐️
26 多线程变量竞争引起的问题 threading V1.0 ⭐️⭐️⭐️
27 多线程锁 threading,lock V1.0 ⭐️⭐️⭐️
28 时间转数组及常用格式 time,datetime,format V1.0 ⭐️⭐️⭐️
29 nonlocal用于内嵌函数中 nonlocal V2.0 ⭐️⭐️⭐️⭐️⭐️
30 global 声明全局变量 global V2.0 ⭐️⭐️⭐️⭐️⭐️
31 共享变量未绑定之坑 global V1.0 ⭐️
32 优化代码异常输出包 debugger V1.0 ⭐️
33 一行代码找到编码 chardet V1.0 ⭐️
34 创建SQLite连接 SQLite v1.0 ⭐️
35 json对象转python对象 python json v1.0 ⭐️
36 python对象转json对象 python json v1.0 ⭐️
37 一行代码让 pip 安装加速 100 倍 pip install v1.0 ⭐️

工作常用案例

小例子 链接 标签 版本 难度
1 不用else和if实现计算器 operator V1.0 ⭐️⭐️⭐️
2 去最求平均 list,sort,round V1.0 ⭐️⭐️⭐️⭐️
3 打印99乘法表 for,range,format V1.0 ⭐️⭐️⭐️
4 递归版flatten函数 recursion,list,isinstance V1.0 ⭐️⭐️⭐️⭐️
5 列表等分为n份 list,ceil V1.0 ⭐️⭐️⭐️
6 压缩列表 list,filter V1.0 ⭐️⭐️⭐️⭐️
7 求更长的列表 max,lambda V1.0 ⭐️⭐️⭐️⭐️⭐️
8 求列表众数 max,lambda,count V1.0 ⭐️⭐️⭐️⭐️
9 所有多个列表的最大值 max,lambda V1.0 ⭐️⭐️⭐️⭐️
10 列表检查重复 set V1.0 ⭐️⭐️⭐️
11 浮点数等差数列 range,float V1.0 ⭐️⭐️⭐️⭐️
12 按条件分组 lambda V1.0 ⭐️⭐️⭐️⭐️
13 map实现向量运算 map,lambda V1.0 ⭐️⭐️⭐️
14 值最大的字典 max,lambda V1.0 ⭐️⭐️⭐️⭐️
15 合并两个字典 ** V1.0 ⭐️⭐️⭐️
16 Topn 字典 heapq,nlargest V1.0 ⭐️⭐️⭐️
17 判断是否为异位词 collections,Counter V1.0 ⭐️⭐️⭐️
18 逻辑上合并字典 ChainMap V1.0 ⭐️⭐️⭐️⭐️⭐️
19 sample 样本抽样 random,sample V1.0 ⭐️⭐️⭐️
20 重洗数据集 shuffle V1.0 ⭐️⭐️⭐️
21 10个均匀分布的坐标点 random,uniform V1.0 ⭐️⭐️⭐️
22 10个高斯分布的坐标点 random,gauss V1.0 ⭐️⭐️⭐️⭐️
23 是否互为排序词 collections,defaultdict V1.0 ⭐️⭐️⭐️⭐️
24 str1是否由str2旋转而来 str V1.0 ⭐️⭐️⭐️
25 寻找第n次出现位置 enumerator V1.0 ⭐️⭐️⭐️
26 找出所有重复元素 calendar,datetime V1.0 ⭐️⭐️⭐️⭐️
27 联合统计次数 Counter V1.0 ⭐️⭐️⭐️⭐️⭐️
28 求两点球面距离 math asin V1.0 ⭐️⭐️⭐️⭐️⭐️
29 获取文件编码 chardet V1.0 ⭐️⭐️⭐️⭐️⭐️
30 格式化json串 json V1.0 ⭐️⭐️⭐️⭐️⭐️

Python原创教程

这是经过很久打磨的一个Python教程,全部是个人原创,已首发在公众号,并且托管在我的个人网站

想系统入门Python的欢迎学习:

Python进阶完整教程

Python前言

Google Python代码风格指南

Python关于数字的20个操作

Python数字

Python正则之提取正整数和大于0浮点数

Python字符串

CSV读写乱码问题

Unicode标准化

Unicode, UTF-8, ASCII

Python动态生成变量

Python字符串对齐

Python小项目1:文本句子关键词的KWIC显示

Python列表

Python流程控制

Python编程习惯专题

Python函数专题

Python面向对象编程-上篇

Python面向对象编程-下篇

Python十大数据结构使用专题

Python包和模块使用注意事项专题

Python正则使用专题

Python时间专题

Python装饰器专题

Python迭代器使用专题

Python生成器使用专题

Python 绘图入门专题

Matplotlib绘图基础专题

Matplotlib绘图进阶专题

Matplotlib绘图案例

NumPy图解入门

NumPy入门教程

1 NumPy介绍

2 安装和导入NumPy

3 Python列表和NumPy数组有什么区别?

4 什么是array?

5 有关Array的详细信息

6 如何创建array

7 添加、删除和排序元素

8 数组形状和大小

9 重塑array

10 如何将一维array转换为二维array(如何向数组添加新轴)

11 NumPy索引和切片

12 如何从现有数据创建数组

13 数组基本操作

14 广播

15 更有用的数组操作

16 生成随机数

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].