title: Creating a company week number & year in pandas
body: <p>assume that we have the following df</p>
  
  <pre><code>import pandas as pd
  
  data = {'Dates' : ['2018-10-15', '2018-02-01', '2018-04-01']}
  data['Dates'] = pd.to_datetime(data.Dates)
  
  print(df)
      Dates
  0   2018-10-15
  1   2018-02-01
  2   2018-04-01
  </code></pre>
  
  <p>in my current company, we have a financial week structure which I normally work out using an excel and I'd like to do this in Python</p>
  
  <p>I use the DateTime module to work around my conditions which are as follows</p>
  
  <p>if the month is <code>&gt;= 4</code> (April) the Week number is 1 (so I take the ISO week number and subtract 13) </p>
  
  <p>if the month is <code>&lt; 4</code> I add 39. </p>
  
  <p>I use the same logic for the YEAR if >= 4 then year + 1 else YEAR</p>
  
  <p>I thought I could use a simple for loop that I could use over my dataframe </p>
  
  <pre><code>for x in data.Dates:
      if x.dt.month &gt;= 4:
         df['Week'] = x.dt.week - 13
      else:
          df['Week'] = x.dt.week + 39
  </code></pre>
  
  <p>and for the year</p>
  
  <pre><code>for x in data.Dates:
      if x.dt.month &gt;= 4:
         df['Year'] = FY &amp; x.dt.year + 1
      else:
           df['Year'] = FY &amp; x.dt.year
  </code></pre>
  
  <p>however, the <code>&gt;= 4</code> on both throws formula error. </p>
  
  <p><code>File "&lt;ipython-input-38-eadb99fdd9db&gt;", line 4
      df.Dates.dt.month &gt; 4:
                            ^
  SyntaxError: invalid syntax</code></p>
  
  <p>however, if I do</p>
  
  <p><code>data['Week'] = data.Dates.dt.week</code></p>
  
  <p>this gives all the week numbers, am I missing something basic or essential here?</p>
  
  <p>I hope this is clear and concise, any advice (even how to ask better questions) is appreciated. </p>