摘要:
思路:新增一列,直接用字符串G+身份证号码 import pandas as pd path = "stus.xlsx" df = pd.read_excel(path, names=['班级','姓名','性别','身份证号码'] #为了防止字段不规范,比如多空格等问题 ) df["N身份证号码" 阅读全文
摘要:
例子: 方法: pandas 读入txt文档,按照空格分隔,然后删除空列,用str替换掉得分:,最后生成新的excel文档 import pandas as pd path = '政治.txt' df = pd.read_csv( path, sep=' ', header=None ) df.dr 阅读全文
摘要:
df.apply方法: import pandas as pd path = 'score.xlsx' df = pd.read_excel(path) df['理综'] = df['物理']+df['化学']+df['生物'] df.head() def lizong(x): if x['理综'] 阅读全文
摘要:
读取与生成新的excel文件: import pandas as pd path = "score.xlsx" df = pd.read_excel(path) #读文件 df['主科总分'] = df['语文'] + df['数学'] +df['英语'] #修改文件内容:将主科、理科、文科的总分计 阅读全文