python
文章平均质量分 72
许我少年
这个作者很懒,什么都没留下…
展开
-
R和pands 实现dataframe的Z-score
1、导入函数from scipy.stats import zscore2、实现按行或列的z分数df4=pd.DataFrame(zscore(df3,axis=1)) #实现每行的数据的z分数df4=pd.DataFrame(zscore(df3,axis=0)) #实现每列的数据的z分数sample:实现每行的z分数......原创 2021-08-02 16:36:49 · 1940 阅读 · 0 评论 -
Notes of Python Cookbook (Chr4-Chr6)
第四章:迭代器与生成器4.1 手动遍历迭代器遍历一个可迭代对象中的所有元素,但是却不想使用 for 循环。使用 next() 函数并在代码中捕获 StopIteration 异常。比如,下面的例子手动读取一个文件中的所有行# def manual_iter():# with open('/etc/passwd') as f:# try:# while True:# line = next(f)#原创 2022-04-14 16:07:48 · 248 阅读 · 0 评论 -
Notes of Python Cookbook (Chr1-Chr3)
贴子主要关于自己的读书摘要,涉及到侵权请联系删除第一章:数据结构和算法# 任何的序列(或者是可迭代对象)可以通过一个简单的赋值语句解压并赋值给多# 个变量。唯一的前提就是变量的数量必须跟序列元素的数量是一样的。p= (4,5)x,y = pprint(x,y,end='\n')# 1.2 解压可迭代对象赋值给多个变量record = ('Dave', 'dave@example.com', '773-555-1212', '847-555-1212')name, email, *phon原创 2022-04-13 20:43:47 · 614 阅读 · 0 评论 -
01_Dive_into_python (reading note)
难度:*Don’t bury your burden in saintly silence. You have a problem?page 41如有涉及到**知识版权,联系删除SUFFIXES = {1000: ['KB', 'MB', 'GB', 'TB', 'PB', 'EB','ZB', 'YB'], 1024: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB','EiB', 'ZiB', 'YiB']}def approximate_siz原创 2021-11-30 20:52:16 · 459 阅读 · 0 评论 -
python 习惯用法
1.if not xif x: 等价于 if x and len(x) > 0:if not x: 等价于 if x is None or len(x) == 0:2.enumerate 枚举为x列表每个元素添加序号从第二个参数开始x = [1, 3, 5]for i, e in enumerate(x, 10): # 枚举 print(i, e)in 判断 成员身份x = 'zen_of_python'if 'zen' in x: print('zen i转载 2020-06-06 14:55:58 · 126 阅读 · 0 评论