📜  python计算数据帧中的行减法 - Python代码示例

📅  最后修改于: 2022-03-11 14:46:12.647000             🧑  作者: Mango

代码示例1
# Dataframe:
# Class     math score   reading score   writing score           
# Class 1      65                73           74
# Class 2      69                66           64

df.loc['Difference'] = df.apply(lambda x: x["Class 1"] - x["Class 2"])

# Result:
# Class       math score    reading score   writing score         
# Class 1         65               73            74
# Class 2         69               66            64
# Difference      -3                7            10