Pandas fill nan values using rolling mean

I have a dataset that contains nan values and I am attempting to fill in those values using a rolling average. My code for doing so is as follows:

df = pd.DataFrame({'vals': med_vals})
print(df[353:363])

vals
353 17682.196292
354 13796.403594
355 14880.418179
356 14139.141779
357 15397.070537
358 15108.345602
359 14286.259755
360 14962.745719
361 NaN
362 NaN
df_filled = df.fillna(df.rolling(7,min_periods = 1).mean())
print(df_filled[353:365])

    vals
353 17682.196292
354 13796.403594
355 14880.418179
356 14139.141779
357 15397.070537
358 15108.345602
359 14286.259755
360 14962.745719
361 14795.663595
362 14778.712678
363 14938.605403
364 14785.783692
365 14624.502737
366 14962.745719
367 NaN
368 NaN
369 NaN

How can I make it so my code takes into account previously filled in values when calculating the rolling average?

Edit: I found a method that works but I'm not too happy with it:

 while pd.isnull(df).any().any() == True:
        df.fillna(df.rolling(window=8,min_periods = 7).mean(), inplace = True)

You are getting exactly what you asked for. When you do a rolling average, numpy has the current cell as the right-edge of the window. So, when setting cell 361:

355  356  357  358  359  360  361  362  363  364  365 366
 ^-----------------------------^

Since 361 is a NaN, you get the average of the other six. Continuing:

355  356  357  358  359  360  361  362  363  364  365  366
      ^-----------------------------^
           ^-----------------------------^
                ^-----------------------------^
                     ^-----------------------------^
                          ^-----------------------------^

So, when it's computing a value for 366, it will average from 360 through 366. The only cell in that range that has a value is 360, so that becomes the average. You told it there only needed to be one value in the range to be valid.

You're saying there is an issue, but it is not at all clear to me what you were expecting.