I have two pandas dataframes which I would like to substract. The base dataframe minuend has more indices and columns than the other dataframe subtrahend.
They are defined as following:
minuend = pd.DataFrame(
{"angles": [0, 3, 4], "degrees": [360, 180, 360]},
index=["circle", "triangle", "rectangle"],
)
angles degrees
circle 0 360
triangle 3 180
rectangle 4 360
subtrahend = pd.Series(
[1, 1], index=["circle", "triangle"], name="angles"
).to_frame()
angles
circle 1
triangle 1
The expected result is:
angles degrees
circle -1 360
triangle 3 180
rectangle 3 360
What is the best way to achive this since minuend - subtrahend or minuend.sub(subtrahend_df) does not work out of the box?