title: How to summarize the data to get separate column for each rank in pandas?
body: <p>Table:</p>
  <pre><code>Gate    Status   BUS    Time
  Gate1   Vacant   102    10:00
  Gate2   Occupied 105    10:01
  Gate3   Vacant   114    10:00
  Gate4   Occupied 123    9:55
  Gate5   Occupied 127    10:00
  Gate6   Occupied 126    10:01
  Gate7   Occupied 106    10:01
  Gate1   Vacant   101    10:15
  Gate2   Occupied 113    10:02
  Gate3   Vacant   116    10:01
  Gate4   Occupied 124    10:00
  Gate5   Occupied 129    10:00
  Gate7   Occupied 125    10:20
  Gate1   Vacant   103    10:25
  Gate2   Occupied 112    10:15
  Gate3   Vacant   120    10:30
  Gate4   Occupied  99    10:15
  Gate5   Occupied 131    10:05
  Gate1   Vacant   107    10:29
  Gate2   Occupied 115    10:30
  Gate3   Vacant   125    10:31
  Gate5   Occupied 130    10:15
  Gate1   Vacant   111    10:30
  Gate2   Occupied 121    10:30
  Gate1   Vacant   104    10:32
  Gate2   Occupied 122    10:31
  </code></pre>
  <p>Desired Result:</p>
  <pre><code>Gate    Status   Rank#1 Rank#2  Rank#3  Rank#4  Rank#5...Rank#10 Rank#11...
  Gate1   Vacant   102    101     103     107     109      111        104
  Gate2   Occupied 105    113     112     115     117      121        122
  Gate3   Vacant   114    116     120     125         
  Gate4   Occupied 123    124      99             
  Gate5   Occupied 127    129     131     130         
  Gate6   Occupied 126                        
  Gate7   Occupied 106    125     
  
          
  </code></pre>
  <p>Rank Is given based on time for each group
  Where Rank 1 is for earliest time and last Rank is for latest</p>
  <p>I have tried the following one:</p>
  <pre><code>data_cy_grp2['Rank'] = data_cy_grp2[['Gate','Status','BUS']].sort_values(['Gate','Status','BUS'], ascending=[True, True, False]).groupby(['Gate']).cumcount() + 1
  
  data_cy_grp2[['Gate','Status','BUS','Rank']].pivot(columns='Rank', values='BUS').apply(lambda x: pd.Series(x.dropna().values))
  </code></pre>
  <p>I am not getting the optimum output.</p>
  <p>Please team support.</p>