You can check when your column values equal the maximum of the last five rows determined with the rolling_max
function (http://pandas.pydata.org/pandas-docs/stable/computation.html#moving-rolling-statistics-moments):
>>> stockdata["Close"] == pd.rolling_max(stockdata["Close"], 5)
2013-09-23 09:30:00 False
2013-09-23 09:31:00 False
2013-09-23 09:32:00 False
2013-09-23 09:33:00 False
2013-09-23 09:34:00 False
2013-09-23 09:35:00 True
2013-09-23 09:36:00 False
2013-09-23 09:37:00 False
2013-09-23 09:38:00 True
2013-09-23 09:39:00 True
dtype: bool
If your are not certain you data are always nicely 1-minutly (so the 5 rows are not always equal to 5 mins), you can set the freq
keyword in rolling_max to 1min
.