I want to mutate column c at a specific row by adding that row and another row.
df = pd.DataFrame({
'A': [0,1,2,3],
'B': [0,1,2,3],
'C': [10,10,10,10]
})
mask1 = df['A']==1
mask2 = df['B']==2
df.loc[mask1, 'C'] = df.loc[mask1, 'C'] + df.loc[mask2, 'C']
In the last line, because we are adding two pd.Series together, it tries to match the index and therefore would return NaN instead of the expected 10 + 10=20.
How do I do this properly?