Skip to content Skip to sidebar Skip to footer

Subtraction Of Pandas Dataframes

I am trying to substract two pandas dataframes from each other, but get only NaN results: Dataframe 1: alpha beta 0 1 4 1 2 5 2 3 6 Dataframe 2:

Solution 1:

Either of these work:

df['a'] = df['a'] - df2['gamma']
df['b'] = df['b'] - df2['gamma']

-

df.sub(df2.iloc[:,0],axis=0)

Post a Comment for "Subtraction Of Pandas Dataframes"