title: Pandas Column operation with dates
body: <p>I have a dataframe, mainly with dates. Here is what I want to do</p>
  
  <p>From the old date variable(DTDate), I want to create a new date variable, if the old date is Monday, the new date will be same, but if the old date is any date other than Monday, the new date will give me the date of the next Monday. So finally all the items in new date will be only with Monday.</p>
  
  <p>I have been trying with a function and apply. here is my data set and code</p>
  
  <pre><code>    Date call   DTDate      weekday     weekdayNo
  0   31/12/2014  2014-12-31  Wednesday   3
  1   29/10/2014  2014-10-29  Wednesday   3
  2   28/10/2014  2014-10-28  Tuesday     2
  3   27/3/2015   2015-03-27  Friday      5
  4   27/2/2015   2015-02-27  Friday      5
  5   27/11/2014  2014-11-27  Thursday    4
  6   27/10/2014  2014-10-27  Monday      1
  7   26/3/2015   2015-03-26  Thursday    4
  8   26/2/2015   2015-02-26  Thursday    4
  9   26/12/2014  2014-12-26  Friday      5
  10  26/11/2014  2014-11-26  Wednesday   3
  11  26/10/2014  2014-10-26  Sunday      0
  12  25/3/2015   2015-03-25  Wednesday   3
  13  25/12/2014  2014-12-25  Thursday    4
  14  24/3/2015   2015-03-24  Tuesday     2
  15  24/2/2015   2015-02-24  Tuesday     2
  16  24/12/2014  2014-12-24  Wednesday   3
  17  24/11/2014  2014-11-24  Monday      1
  18  23/3/2015   2015-03-23  Monday      1
  </code></pre>
  
  <p>The code is </p>
  
  <pre><code>from datetime import date, timedelta
  
  def AddDate(row):
      if row['weekdayNo']==0:
          return row['DTDate'] + timedelta(days=1)
      elif row['weekdayNo'] ==2:
          return row['DTDate'] + timedelta(days=6)
      elif row['weekdayNo'] ==3:
         return row['DTDate'] + timedelta(days=5)
      elif row['weekdayNo'] ==4:
         return row['DTDate'] + timedelta(days=4)
      elif row['weekdayNo'] ==5:
         return row['DTDate'] + timedelta(days=3) 
      elif row['weekdayNo'] ==6:
         return row['DTDate'] + timedelta(days=2)
      else:
         return row['DTDate']
  
   DF['newDate'] = DF.apply(AddDate, axis=1)
  </code></pre>
  
  <p>and I am getting the following, it is the exact same thing, nothing changed</p>
  
  <pre><code>     Date call  DTDate       weekday    weekdayNo   newDate
   0  31/12/2014  2014-12-31  Wednesday      3        2014-12-31
   1  29/10/2014  2014-10-29  Wednesday      3        2014-10-29
   2  28/10/2014  2014-10-28  Tuesday        2        2014-10-28
   3  27/3/2015   2015-03-27  Friday         5        2015-03-27
   4  27/2/2015   2015-02-27  Friday         5        2015-02-27
   5  27/11/2014  2014-11-27  Thursday       4        2014-11-27
   6  27/10/2014  2014-10-27  Monday         1        2014-10-27
   7  26/3/2015   2015-03-26  Thursday       4        2015-03-26
   8  26/2/2015   2015-02-26  Thursday       4        2015-02-26
   9  26/12/2014  2014-12-26  Friday         5        2014-12-26
   10 26/11/2014  2014-11-26  Wednesday      3        2014-11-26
   11 26/10/2014  2014-10-26  Sunday         0        2014-10-26
   12 25/3/2015   2015-03-25  Wednesday      3        2015-03-25
   13 25/12/2014  2014-12-25  Thursday       4        2014-12-25
   14 24/3/2015   2015-03-24  Tuesday        2        2015-03-24
   15 24/2/2015   2015-02-24  Tuesday        2        2015-02-24
   16 24/12/2014  2014-12-24  Wednesday      3        2014-12-24
   17 24/11/2014  2014-11-24  Monday         1        2014-11-24
   18 23/3/2015   2015-03-23  Monday         1        2015-03-23
  </code></pre>
  
  <p>I also think, this idea is not good, if there is something better, Please would anyone like to suggest, what that might be?? Thanks in advance</p>