标签:turn imp int xlsx tip 报错 index ret nbsp
1 import pandas 2 excel=pandas.read_excel(‘填充数据.xlsx‘,header=3,index_col=‘id‘) 3 excel[‘mutiply‘]=excel[‘store‘]*0.5 4 for i in excel.index: 5 excel[‘data1‘].at[i]=excel[‘data‘].at[i]*excel[‘store‘].at[i] #data1这个列名必须在excel里面存在,否则程序会报错 6 7 8 excel[‘store‘]=excel[‘store‘]+2 #对着一列的每个元素加2 9 10 def add_2(x): 11 return x+2 12 13 excel[‘data‘]=excel[‘data‘].apply(add_2) #对data这列的每个元素加2,也可以用lambda x:x+2代替 14 print(excel)
标签:turn imp int xlsx tip 报错 index ret nbsp
原文地址:https://www.cnblogs.com/energetic/p/13064692.html