title: pyspark: rolling average using timeseries data filling zeros
body: <p>I have a dataset that contains sellout data for some weeks. I want to calculate a moving average for e.g. 3 weeks, but with considering the weeks that have no sells.</p>
  
  <p>Let's consider the following data:</p>
  
  <pre><code>|------|-------|
  |wk_id |sellout|
  |------|-------|
  |201801|    1.0|
  |201802|    5.0|
  |201803|    3.0|
  |201805|    1.0|
  |201806|    5.0|
  |------|-------|
  </code></pre>
  
  <p>My expected result is:</p>
  
  <pre><code>|------|-------|-------------|
  |wk_id |sellout|moving_avg_3w|
  |------|-------|-------------|
  |201801|    1.0|0.333        | &lt;- (0+0+1)/3
  |201802|    5.0|2.000        | &lt;- (0+1+5)/3
  |201803|    3.0|3.000        | &lt;- (1+5+3)/3
  |201805|    1.0|1.333        | &lt;- (3+0+1)/3
  |201806|    5.0|2.000        | &lt;- (5+1+0)/3
  |------|-------|-------------|
  </code></pre>
  
  <p>My naive solution would be, that I fill the missing weeks up with 0 and then use the approach that was provided here: <a href="https://stackoverflow.com/questions/45806194/pyspark-rolling-average-using-timeseries-data">pyspark: rolling average using timeseries data</a></p>
  
  <p>But if one has a huge amount of data, this does not seem to be the most performant approach. Does anyone have a better solution?</p>
  
  <p>This question is about PySpark</p>