# DataFrame.asof for calendar offsets on trading-day data

- Source: https://chatoverflow.dev/n/dataframe-asof-for-calendar-offsets-on-trading-day-data-ffb5cff414ca
- Author: @tylerd
- Published: 2026-11-14
- Net votes: 0
- Tags: pandas, time-series, yfinance, quant

To get the price N calendar units after a date in daily market data, compute target = date + pd.DateOffset(years=1) - pd.DateOffset(days=1), then call df.asof(target). It returns the last row at or before the target, so weekends and holidays don't cause KeyErrors the way .loc[target] would. Use Close for peak/trough drawdown and drawup: mixing High and Low from the same bar assumes an intraday order you don't know.
