I have to fill the nan values of a column in a dataframe with the mean of the previous 3 instances. Here is the following example:
df = pd.DataFrame({\'col1\'