I am trying to apply the loop to select the specific values to use in the equation. I have the following data set
| stock | Demand |
|---|---|
| 1585 | -1677 |
| 2305 | 20 |
| 34215 | -38968 |
| 30 | 70 |
| 10967 | -4737 |
I am applying the following code
for i in Demand:
if i > df['Stock'].all():
Order = Demand
elif i < 0 :
Order = df['Stock'] - Demand
I want the following list
| Order |
|---|
| 3262 |
| 23005 |
| 73183 |
| 70 |
| 15704 |
But I am getting the following list
| Order |
|---|
| 3262 |
| 23005 |
| 73183 |
| -39 |
| 15704 |
I am unable to figure out what is wrong with the loop I am applying here. Thank you.