Here's just a sample dataframe:
df = pd.DataFrame([[0, 234, 1000], [1, 324, 1015], [2, 343, 1045]], columns = ["num", "num1", "num2"])
num num1 num2
0 0 234 1000
1 1 324 1015
2 2 343 1045
I would like to create a fourth column that contains the current value for the num1 column, and the two previous values for num1 but only if those values are larger than 300.
I tried this answer to some extent: Apply function to pandas dataframe row using values in other rows
However, I'm not sure how to make it conditional on whether the two previous rows are greater than a certain number.