python和pandas处理excel(5)
作者:
OURPIECE | 来源:发表于
2020-08-29 15:00 被阅读0次
列、单元格计算
场景1
import pandas as pd
df = pd.read_excel("E:/test.xlsx",index_col='ID')
df['Price']=df['Price1'] * df['Price2'] //列与列的计算
for i in range(4:10):
df.at[i,'Price'] = df.at[i,'Price1'] * df.at[i,'Price2'] //单元格与单元格计算
场景2
import pandas as pd
df = pd.read_excel("E:/test.xlsx",index_col='ID')
df['Price']=df['Price'] + 2 //列与列的计算
df['Price']=df['Price'].apply(lambda x:x+2) //结果同上
本文标题:python和pandas处理excel(5)
本文链接:https://www.haomeiwen.com/subject/kjpmdktx.html
网友评论