摘要: merge merge的参数 on:列名,join用来对齐的那一列的名字,用到这个参数的时候一定要保证左表和右表用来对齐的那一列都有相同的列名。 left_on:左表对齐的列,可以是列名,也可以是和dataframe同样长度的arrays。 right_on:右表对齐的列,可以是列名,也可以是和da 阅读全文
posted @ 2022-04-29 17:30 牛奶加布丁 阅读(2164) 评论(0) 推荐(0)
摘要: 原文:https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p03_create_new_iteration_with_generators.html 4.1 手动遍历迭代器 为了手动的遍历可迭代对象,使用 next() 函数并在代码中捕获 阅读全文
posted @ 2022-04-29 11:04 牛奶加布丁 阅读(47) 评论(0) 推荐(0)
摘要: format() 1.通过位置来填充字符串 print('hello {0} i am {1}'.format('world','python')) # 输入结果:hello world i am python print('hello {} i am {}'.format('world','pyt 阅读全文
posted @ 2022-04-28 19:50 牛奶加布丁 阅读(237) 评论(0) 推荐(0)
摘要: assert(断言) assert(断言)用于判断一个表达式,在表达式条件为 false 的时候触发异常。 assert expression import sys assert ('linux' in sys.platform), "该代码只能在 Linux 下执行" import sys pri 阅读全文
posted @ 2022-04-28 15:29 牛奶加布丁 阅读(63) 评论(0) 推荐(0)
摘要: 各空值类型 df=pd.DataFrame() df['a']=pd.NaT # datetime64[ns] # pandas中pd.NaT表示 not a time。 df['b']=np.nan # float64 # NaN是numpy\pandas下的,不是Python原生的,Not a 阅读全文
posted @ 2022-04-28 12:07 牛奶加布丁 阅读(4892) 评论(0) 推荐(0)
摘要: 数据分析与预处理 查看样本数据是否均衡 样本不均衡解决方案 (1)下采样 让正常样本和异常样本数据一样少。 缺点:原始数据很丰富,下采样过后,只利用了其中一小部分。 (2)过采样 让异常样本和正常样本一样多。 缺点:异常数据是造出来的。 特征标准化 数据特征决定结果的上限,而模型的调优只决定如何接近 阅读全文
posted @ 2022-03-30 19:15 牛奶加布丁 阅读(185) 评论(0) 推荐(0)
摘要: 回归算法 线性回归方程 $h_{\theta }(x) =\theta _{0} +\theta _{1}x_{1}+\theta _{2}x_{2}=\sum_{i=0}^{n}\theta _{i}x_{i}=\theta ^{T}x$ $\theta _{0}$为偏置项 误差项分析 误差项:真 阅读全文
posted @ 2022-03-26 17:08 牛奶加布丁 阅读(214) 评论(0) 推荐(0)
摘要: Numpy 1、ndarray中所有元素必须是同一类型,否则会自动向下转换,int→float→str 2、得到索引位置 df['amount'].argmin()out:最小值的index 3、用元素的索引位置替代排序后的实际结果 np.argsort(df['amount']) 4、按照大小顺序 阅读全文
posted @ 2022-03-26 15:17 牛奶加布丁 阅读(165) 评论(0) 推荐(0)
摘要: 1.to_categorical的功能 简单来说,to_categorical就是将类别向量转换为二进制(只有0和1)的矩阵类型表示。其表现为将原有的类别向量转换为独热编码的形式。先上代码看一下效果: from keras.utils.np_utils import * #类别向量定义 b = [0 阅读全文
posted @ 2022-03-25 17:16 牛奶加布丁 阅读(484) 评论(0) 推荐(0)
摘要: 只提取数值 def _get_number(my_str): number = filter(str.isdigit,my_str ) strs_unmber="".join(list(number)) return strs_unmberall_apply['certificate_no_d']= 阅读全文
posted @ 2021-11-25 10:13 牛奶加布丁 阅读(469) 评论(0) 推荐(0)