Trying to add a cumulative column to a pandas df.
Have tried this code but get a NaNs:
df['Total_Coins_Bought'] = df.query("side == 'buy'")['amount'].cumsum()
df['Total_Coins_Sold'] = -df.query("side == 'sell'")['amount'].cumsum()
df['Total_Coins'] = df['Total_Coins_Bought']-df['Total_Coins_Sold']
Only looking to build the Total_Coins column; the 2 fields Total_Coins_Bought & Total_Coins_Sold are me just trying to build this step by step