![](https://img-blog.csdnimg.cn/20190918140012416.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
Python
python处理中遇到的各类问题记录
Moonset1995
这个作者很懒,什么都没留下…
展开
-
Python读取已有文件,删除并更新数据进入指定sheet(File is not a zip file和文件损坏报错问题解决方法)
import pandas as pdimport numpy as npfrom openpyxl import load_workbookbook = load_workbook(r'C:\Users\zhimin.liu\Desktop\数据存储test.xlsx')try: ws = book["insert_test"] book.remove(ws) #删除需要替换的sheetexcept: print('无需删除的shee.原创 2022-03-28 11:40:16 · 3210 阅读 · 1 评论 -
python进行md5(32位)转化并输出txt文件
import pandas as pd import hashlib def hashing_num(temp_num): a = temp_num.encode('utf-8') a = hashlib.md5(a).hexdigest() #调用hashlib包中的md5方法对单个字符串进行md5转化 return a #读取excel电话号码数据df = pd.read_excel(r'C:\Users\NING MEI\Desktop\手机号.xlsx'原创 2020-11-22 17:27:18 · 1422 阅读 · 0 评论 -
dataframe groupby 出现错误 incompatible index of inserted column with frame index
新增一列用于储存分组计算后的值有时候会出现错误:incompatible index of inserted column with frame index该问题应为groupby计算生成的为series,其产生了索引导致不能直接插入一个“列”中。产生的series如下:所以在赋值的时候应直接赋值series的value,我计算的是分组然后计算偏移量,代码如下:#书时间排序,我这里是可以直接排序的,如果有需要可以进行分组时间排序,加个group by 并且用apply使用匿名函数进行排序即可df原创 2020-05-20 10:36:07 · 12417 阅读 · 3 评论