I have the below dataframe. I would like to return a second column that is the sum of every item in the column with a condition: only those larger than -1.
input
Price
0 12
1 14
2 15
3 10
4 2
5 4
6 -5
7 -4
8 -3
9 -5
10 16
11 15
output
Price Total Sum
0 12 88
1 14
2 15
3 10
4 2
5 4
6 -5
7 -4
8 -3
9 -5
10 16
11 15
df["Positive"] = max(df["Price"], 0)thenresult = df["Positive"].sum()sum([c for c in col if c >= 0])?