Python
文章平均质量分 64
晴朗的心情
这个作者很懒,什么都没留下…
展开
-
Python xlsxwriter BytesIO 创建excel 文件
@action(methods=['get'], detail=False) def example_export(self, request, *args, **kwargs): ''' 模板下载 ''' try: row1 = ['项目基本信息', '项目进度'] row2 = ['(*)项目编号', '(*)项目名称', '(*)项目类型', '(*)当前进度(进行中)',...原创 2022-03-15 16:46:10 · 688 阅读 · 0 评论 -
【pandas】数据分析常用函数
文章目录apply列处理行处理apply行或列合理函数应用列处理def get_event_time(row): if row is not NaT and row: return datetime.strptime(row, "%Y-%m-%dT%H:%M:%S+08:00") else: return Nonedf['eventTime'] = df['eventTime'].apply(原创 2022-03-03 18:19:08 · 474 阅读 · 0 评论 -
[python]操作文件
文章目录读取json 文件读取json 文件 with open('acs_door_v2_list.json', 'r', encoding='utf-8') as r: # todo 测试代码 asc_door_list = json.loads(r.read()) # todo 测试代码 df = pd.DataFrame(asc_door_list)...原创 2021-10-26 10:02:07 · 79 阅读 · 0 评论 -
【Pandas】坑点
文章目录数据分组group数据分组group分组的数据,分组前总得数据量,应该等于分组后,每组len加起来的总和chushi_len=len(df) b = list() for index, groupdf in df.groupby(by=group_list): index_value = [] index_value.append(len(groupdf))...原创 2019-07-23 08:54:07 · 160 阅读 · 0 评论 -
【python-sqlalchemy】sqlalchemy用法积累
文章目录连接数据库(mysql)通过已有表,生成对应model连接数据库(mysql)通过已有表,生成对应model原创 2019-04-15 13:51:39 · 294 阅读 · 0 评论 -
[Scrapy]学习历程
文章目录环境安装初步爬虫环境安装这里建议使用anconda安装,直接用pip install Scrapy的话容易报错安装ancondacmd打开终端 创建虚拟环境输入命令:conda create -n scrapy_env安装 scrapy 命令:conda install scrapy检查安装的包 命令:pip list初步爬虫创建一个项目 scrapy star...原创 2019-02-22 15:43:22 · 147 阅读 · 0 评论 -
【Pandas】常规方法使用
文章目录countcountimport pandas as pda=[['1','2','5'],['1','4','7'],['2','5','6']]b=pd.DataFrame(a,columns=['a','b','c'])print(b[b['a']=='1'].a.count())原创 2018-11-11 14:54:58 · 1229 阅读 · 0 评论 -
【Python】基础用法
文章目录%format()()面向对象模板拼接+joinf-string%%号格式化字符串的方式继承自古老的C语言,这在很多编程语言都有类似的实现。上例的%s是一个占位符,它仅代表一段字符串,并不是拼接的实际内容。实际的拼接内容在一个单独的%号后面,放在一个元组里。print('%s %s' % ('hello','python'))format()s1 = 'Hello {}! My...原创 2018-11-02 14:03:43 · 304 阅读 · 0 评论 -
【Python】基础爬虫
文章目录常用库urllib常用库urllibrequest它是最基本的 HTTP 请求模块,可以用来模拟发送请求 就像在浏览器里输入网挝然后回车 样,只需要给库方法传入 URL 及额外的 数,就可以模拟实现这个过程了。urlopen()import urllib.requestresponse = urllib.request.urlopen('https://www.pyt...原创 2018-11-01 14:36:15 · 177 阅读 · 0 评论 -
【python】时间处理
文章目录时间转换成时间戳时间戳转换成时间时间转换成时间戳import timefrom datetime import datetimetime_stamp = int(time.mktime( datetime.strptime(my_time_str, "%Y-%m-%d %H:%M:%S").timetuple()))时间戳转换成时间import原创 2018-10-19 10:26:12 · 247 阅读 · 0 评论 -
[pandas]高级使用
目录读写文本格式序列化使用数据库合并数据集重塑和轴向旋转数据转换读写文本格式CSV(Comma-Separated Values)格式的文件是指以纯文本形式存储的表格数据,这意味着不能简单的使用Excel表格工具进行处理,而且Excel表格处理的数据量十分有限,而使用Pandas来处理数据量巨大的CSV文件就容易的多了。如何读取csv数据 r...原创 2018-09-14 12:36:04 · 599 阅读 · 0 评论