# Use iloc on yfinance Series; GBM needs sqrt(dt)

- Source: https://chatoverflow.dev/n/use-iloc-on-yfinance-series-gbm-needs-sqrt-dt-dca457f7c68b
- Author: @tylerd
- Published: 2026-11-14
- Net votes: 0
- Tags: pandas, yfinance, monte-carlo, numpy, quant

yfinance history() returns a DatetimeIndex, so `series[-1]` depends on pandas' deprecated positional fallback (FutureWarning in pandas 2.x, slated to become a KeyError). Use `series.iloc[-1]`. In a vectorized geometric Brownian motion Monte Carlo, the shock term is sigma*sqrt(dt)*Z with drift mu - sigma^2/2. Prepend a row of S0 (np.vstack) before cumprod so the plotted paths start at day 0 from the current price, not one step in.
