2021年6月23日

pandas如何处理跳过表头操作

摘要: 1.打印前5行数据,发现存在‘NAN’ 2.如果这个问题不处理,后续要到操作列时,会报错误‘'DataFrame' object is not callable’ 思路: 跳过有NAN的行 def to_split(): xl = pd.ExcelFile("d:/work/加班统计/11月份工时表 阅读全文

posted @ 2021-06-23 11:56 平凡之测 阅读(1716) 评论(0) 推荐(0) 编辑

2021年6月22日

python 将字典转换为列表

摘要: 在实现功能时,有时候有些函数适用于非字典形式 这时候就需要把字典转换为其他形式 本例主要讲解字典到列表转换 datas=[{'1':'nihao'},{'2':'very goog'}] to_list=[] for dic in datas: #print(dic) to_list=list(di 阅读全文

posted @ 2021-06-22 10:22 平凡之测 阅读(3114) 评论(0) 推荐(0) 编辑

python 字典使用

摘要: 整理很好的文章 文章复制链接: https://mp.weixin.qq.com/s/Aj65A-uuTaARW3vvYTxvzQ 1、检查键是否存在于字典中 def key_in_dict(d, key): return key in d d = {'Bob': 1, 'Mary': 2, 'Li 阅读全文

posted @ 2021-06-22 08:14 平凡之测 阅读(76) 评论(0) 推荐(0) 编辑

2021年6月21日

openpyxl 写入字典

摘要: def write(self,data_path, sheetname,value): index = len(value) workbook = openpyxl.Workbook() sheet = workbook.active sheet.title = sheetname for i in 阅读全文

posted @ 2021-06-21 11:27 平凡之测 阅读(570) 评论(0) 推荐(0) 编辑

遍历列表、元组或字符串的函数enumerate

摘要: 这两天在处理遇到的问题,循环遍历列表中的字典并输出到excel中 查阅资料发现了一个正和我意的函数 所以周一一上班我就开始试一试 然而发现 enumerate函数只适用于列表、元组或字符串的函数 语法: seq = ['one', 'two', 'three'] for i, element in 阅读全文

posted @ 2021-06-21 08:43 平凡之测 阅读(143) 评论(0) 推荐(0) 编辑

2021年6月18日

打印输出列表里的字典

摘要: 格式[{1:2},{3:4},{5:6}] a=[{1:2},{3:4},{5:6}] for dic in a: for i in dic: print(i,dic[i]) 阅读全文

posted @ 2021-06-18 16:43 平凡之测 阅读(196) 评论(0) 推荐(0) 编辑

python 两个函数间如何调用

摘要: def a(): pass def b(): pass s=a() b(s) 或者 b(a()) 阅读全文

posted @ 2021-06-18 10:49 平凡之测 阅读(242) 评论(0) 推荐(0) 编辑

2021年6月17日

python xlrd 读取表格 单元格值被覆盖

摘要: 代码实现顺序: 按行读取 按列读取 满足if条件 单元格值赋值给字典 实现代码: datas = []# 定义一个空列表 for i in range (3,nrows): sheet_data={}# 定义一个空字典 for j in range(ncols): c_type=table.cell 阅读全文

posted @ 2021-06-17 16:04 平凡之测 阅读(146) 评论(0) 推荐(0) 编辑

2021年6月11日

python xlrd xlwr函数 读取excel好文总结

摘要: https://www.cnblogs.com/python-robot/p/9958352.html 官网: http://www.python-excel.org/ 好文: https://www.cnblogs.com/insane-Mr-Li/p/9092619.html 读取excel数据 阅读全文

posted @ 2021-06-11 14:50 平凡之测 阅读(94) 评论(0) 推荐(0) 编辑

TypeError: 'NoneType' object is not iterable 一次错误场景

摘要: TypeError: 'NoneType' object is not iterable 源码 def get_url(lines): urls=[] for line in lines: if 'img' in urls: url=line.split('src=')[-1].split('"') 阅读全文

posted @ 2021-06-11 10:31 平凡之测 阅读(235) 评论(0) 推荐(0) 编辑

导航