title: Extracting the week from python datetime and getting the serial number?
body: <p>I have a dataframe with column name order date containing date from July 2014 to June 2015 in the format 2014-10-17 15:11:54. Using datetime I have extracted the week number from the date. However I get the starting week as 27 for July 2014 than for January 2015 starts again as week 1. What I want is July 2014 as week 1 continue till June 2015 and ends as 53.</p>
  
  <pre><code>df['Week'] = df.order_date.dt.week 
  </code></pre>
  
  <p>Use the above code to get the week number after that to get as 1 for July 2014 use</p>
  
  <pre><code>def time_period(x):
      if df.Week &gt;= 26:
          return df.Week -25
      else:
          return df.Week +28
  df['week_serial'] = df.Week.apply(lambda x: time_period(x))
  </code></pre>
  
  <p>This gives an error- The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().</p>