2020年7月16日
摘要: pandas的apply函数是自动根据function遍历每一个数据,然后返回一个数据结构为Series的结果 DataFrame.apply(func, axis=0, broadcast=False, raw=False, reduce=None, args=(), **kwds) 参数解释: 阅读全文
posted @ 2020-07-16 11:08 小小喽啰 阅读(4801) 评论(0) 推荐(0) 编辑
  2020年7月15日
摘要: 前面已经做了类别和连续特征的分析,本文将针对特征工程进行 导入数据 import pandas as pd import numpy as np import matplotlib import matplotlib.pyplot as plt import seaborn as sns %matp 阅读全文
posted @ 2020-07-15 18:32 小小喽啰 阅读(518) 评论(0) 推荐(0) 编辑
摘要: 1.生成numpy import numpy as np #1.array,里面需要是数组 np.array([[1,2,3],[2,3,4]]) np.array([(1,2,3),(1,3,4)]) #2.arange,np.arange(start,stop,step),和range用法基本相 阅读全文
posted @ 2020-07-15 17:27 小小喽啰 阅读(157) 评论(0) 推荐(0) 编辑
摘要: Python内置的@property装饰器就是负责把一个方法变成属性调用的 class Student(object): @property def score(self): return self._score @score.setter def score(self, value): if no 阅读全文
posted @ 2020-07-15 14:35 小小喽啰 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 同一个类下,不同实例定义的属性或者方法,其他实例如果没有定义是不能使用的 #定义一个类 class Student(object): pass #给类绑定一个实例 s=Student() #给实例绑定一个属性 s.name='Micheal' s.name #'Micheal' s1=Student 阅读全文
posted @ 2020-07-15 14:31 小小喽啰 阅读(114) 评论(0) 推荐(0) 编辑
  2020年7月14日
摘要: 目录 1.类和实例 1.1类和实例的概念 1.2类的属性 1.3类的方法 1.4类的访问限制 2.继承和多态 2.1继承的概念 2.2多态 正文 一、类和实例 1.类(Class)和实例(Instance)的概念 类就是一个抽象的模板,而实例就是类的一个个具体的对象,如动物就是一个类,而猪、狗、鸡等 阅读全文
posted @ 2020-07-14 18:59 小小喽啰 阅读(511) 评论(0) 推荐(0) 编辑
摘要: 关于偏函数这个知识点,廖雪峰老师官网说的比较简单,我就再参考了另外一个花里花俏的园子:https://www.cnblogs.com/sui776265233/p/9881628.html#_label0 先引出偏函数 #一个带有可变参数的sum函数 def sum(*args): s=0 for 阅读全文
posted @ 2020-07-14 17:21 小小喽啰 阅读(788) 评论(0) 推荐(0) 编辑
摘要: 先看一个例子 #这个是一个闭包,闭包前面已经说了 def log(func): def wrapper(*args, **kw): print('call %s():' % func.__name__) return func(*args, **kw) return wrapper @log def 阅读全文
posted @ 2020-07-14 16:03 小小喽啰 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 先看一个例子 list(map(lambda x:x*x,[1,2,3,4,5])) 关键字lambda 表示匿名函数,冒号前面的x表示函数参数,冒号后面是表达式 匿名函数有个限制,就是只能有一个表达式,不用写return,返回值就是该表达式的结果 如果是判断表达式,则和filter配合使用,如果是 阅读全文
posted @ 2020-07-14 15:02 小小喽啰 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 我们先来看一个函数 def lazy_sum(*args): def sum(): ax=0 for n in args: ax=ax+n return ax return sum #调用 f=lazy_sum(1,2,3,4,5) f #<function __main__.lazy_sum.<l 阅读全文
posted @ 2020-07-14 14:45 小小喽啰 阅读(124) 评论(0) 推荐(0) 编辑