Question: ```
# import webdriver
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import WebDriverException

# create webdriver object
driver = webdriver.Firefox()

url = "https://www.zalando.no/tommy-jeans-tjm-essential-down-vest-vest-court-blue-tob22t06j-k11.html"
driver.get(url)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,'//*[@id="uc-btn-accept-banner"]'))).click()
driver.find_element(By.XPATH, "/html/body/div[4]/div/div[1]/div/div/div[2]/div[1]/x-wrapper-re-1-6/div/div[2]/button/span").click()
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,"/html/body/div[9]/div/div[3]/div/form/div/div[4]/div/label/span/div/span"))).click()

```

I'm trying to create a sneaker bot for fun. When I click to select shoes size I can't locate the element for some reason.

Answer: 
**Update**:

A more straightforward approach inspired by your code using `clip` and without `numpy`:

```
diff = df['Incoming'].sub(df['Outgoing'])
df['Total'] = diff.mul(diff.ge(0).cumsum().clip(0, 1)).cumsum()
print(df)

# Output:
   Incoming  Outgoing  Total
0         0       150      0
1        10        20      0
2       100        30     70
3        50        70     50

```

---

Old answer:

Find the row where the balance is positive for the first time then compute the cumulative sum from this point:

```
start = np.where(df['Incoming'] - df['Outgoing'] >= 0)[0][0]

df['Total'] = df.iloc[start:]['Incoming'].sub(df.iloc[start:]['Outgoing']) \
                .cumsum().reindex(df.index, fill_value=0)

```

Output:

```
>>> df
   Incoming  Outgoing  Total
0         0       150      0
1        10        20      0
2       100        30     70
3        50        70     50

```
IIUC, you can check when Incoming is greater than Outgoing using `np.where` and assign a helper column. Then you can check when this new column is not null, using `notnull()`, calculate the difference, and use `cumsum()` on the result:

```
df['t'] = np.where(df['Incoming'].ge(df['Outgoing']),0,np.nan)
df['t'].ffill(axis=0,inplace=True)

df['Total'] = np.where(df['t'].notnull(),(df['Incoming'].sub(df['Outgoing'])),df['t'])
df['Total'] = df['Total'].cumsum()

df.drop('t',axis=1,inplace=True)

```

This will give back:

```
   Incoming  Outgoing  Total
0         0       150    NaN
1        10        20    NaN
2       100        30   70.0
3        50        70   50.0

```