title: Index Error: Columns status already selected
body: <p>have a data frame data as below</p>
  <pre><code>   InsuranceId InsuranceStatus  Date
  0  Ins1234     DuePayment       2020-06-07 23:59:43.123456+00:00
  1  Ins1234     Successful       2019-06-07 23:59:43.123456+00:00
  2  Ins1234     Successful       2018-06-07 23:59:43.123456+00:00
  3  Ins5678     DuePayment       2020-07-07 22:59:32.123421+00:00
  4  Ins5678     Successful       2019-07-07 22:59:32.123421+00:00
  5  Ins5678     Successful       2018-07-07 22:59:32.123421+00:00
  </code></pre>
  <p>trying to create a rownumber/rank on basis of group by InsuranceId and max(Date)</p>
  <pre><code>df['RowNum'] = df.groupby('InsuranceId')['InsuranceStatus']['Date'].rank(method=&quot;first&quot;, ascending=True)
  
  and 
  
  df['RowNum'] = df.groupby(by=['InsuranceId'])['InsuranceStatus']['Date'].transform(lambda x: x.rank())
  </code></pre>
  <p>by referring <a href="https://stackoverflow.com/questions/17775935/sql-like-window-functions-in-pandas-row-numbering-in-python-pandas-dataframe">SQL-like window functions in PANDAS: Row Numbering in Python Pandas Dataframe</a></p>
  <pre><code>Error: Index Error: Columns status already selected 
  </code></pre>
  <p>trying to achieve below output</p>
  <pre><code>   InsuranceId InsuranceStatus  Date                                RowNum
  0  Ins1234     DuePayment       2020-06-07 23:59:43.123456+00:00    1
  1  Ins1234     Successful       2019-06-07 23:59:43.123456+00:00    2
  2  Ins1234     Successful       2018-06-07 23:59:43.123456+00:00    3
  3  Ins5678     DuePayment       2020-07-07 22:59:32.123421+00:00    1
  4  Ins5678     Successful       2019-07-07 22:59:32.123421+00:00    2
  5  Ins5678     Successful       2018-07-07 22:59:32.123421+00:00    3
  </code></pre>
  <p>Is there anything i am missing to add. pls any suggestions</p>
  <p>Final output:</p>
  <pre><code>   InsuranceId InsuranceStatus  Date                                
     Ins1234     DuePayment       2020-06-07 23:59:43.123456+00:00    
     Ins5678     DuePayment       2020-07-07 22:59:32.123421+00:00    
  </code></pre>