sum column above/below current row in pandas
This is cumsum:
df['X'] = df['C'].cumsum()
df['Y'] = df['C'].sum() + df['C'] - df['X']
# or
# df['Y'] = df.iloc[::-1].cumsum()
Let us try with expanding
you can chose the agg function you need etc, mean
/std
df['X'] = df['C'].expanding().sum()
df['Y'] = df['C'].iloc[::-1].expanding().sum()