title: Problems with a for loop when replacing values in a pandas dataframe
body: <p>The following line of code replaces the value for april 2020 with the mean value of the same month the four previous years in a pandas dataframe.</p>
  <pre><code>df.loc[df['Time'] == '2020-04-30', 'value'] = df.loc[df['column'].isin(['2019-04-30', '2018-04-30', '2017-04-30', '2016-04-30' ]), 'value'].mean()
  </code></pre>
  <p>I want to do the same operation on may, june, july etc. and started to work on a for loop. I havent dont a loop before with four diffrent values and I tries the above. But it only seeam to work for the first iteration? What am I missing?</p>
  <pre><code>date = [('2020-04-30', '2019-04-30', '2018-04-30', '2017-04-30', '2016-04-30'),
         ('2020-05-30', '2019-05-30', '2018-05-30', '2017-05-30', '2016-05-30')]
  
  for i, j, k, l, m in date:
      df1.loc[df1['Time'] == i, 'AF_ARBETSLOSA'] = df1.loc[df1['Time'].isin([j, k, l, m]), 'AF_ARBETSLOSA'].mean()
  </code></pre>
  <p>I also tried this, but an error was returned &quot;Lenghts must match&quot;.</p>
  <pre><code>y2020 = [('2020-04-30', '2020-05-30', '2020-06-30', '2020-07-30')]
  y2019 = [('2019-04-30', '2019-05-30', '2019-06-30', '2019-07-30')]
  y2018 = [('2018-04-30', '2018-05-30', '2018-06-30', '2018-07-30')]
  y2017 = [('2017-04-30', '2017-05-30', '2017-06-30', '2017-07-30')]
  y2016 = [('2016-04-30', '2016-05-30', '2016-06-30', '2016-07-30')]
  
  
  for i, j, k, l, m in zip(y2020, y2019, y2018, y2017, y2016):
      df1.loc[df1['Time'] == i, 'AF_ARBETSLOSA'] = df1.loc[df1['Time'].isin([j, k, l, m]), 'AF_ARBETSLOSA'].mean()
  </code></pre>
  <p>My data looks like this:</p>
  <pre><code>              n
  Time    
  1994-01-31  636790
  1994-02-28  622556
  1994-03-31  609128
  1994-04-30  588751
  1994-05-31  579768
  </code></pre>