title: Grouped Cummulative Max in pandas
body: <pre><code>import pandas as pd
  
  gender = {'Type': [&quot;Male&quot;,&quot;Male&quot;,&quot;Male&quot;,&quot;Female&quot;,&quot;Female&quot;,&quot;Female&quot;,&quot;Male&quot;,&quot;Male&quot;,&quot;Male&quot;,&quot;Female&quot;,&quot;Female&quot;,&quot;Female&quot;,&quot;Female&quot;,&quot;Male&quot;,&quot;Male&quot;,&quot;Female&quot;,&quot;Female&quot;,&quot;Female&quot;], 
            'Age': [40, 22, 23, 55, 75, 31, 22, 23, 26, 29, 33, 32, 40, 41, 47, 48, 54]}
  
  df = pd.DataFrame.from_dict(gender)
  
  print(df)
            
       Type  Age
  0     Male   40
  1     Male   22
  2     Male   23
  3   Female   55
  4   Female   75
  5   Female   31
  6     Male   22
  7     Male   23
  8     Male   26
  9   Female   29
  10  Female   33
  11  Female   32
  12  Female   40
  13    Male   41
  14    Male   47
  15  Female   48
  16  Female   54
  
  
  Expected Output
  
       Type  Age      Group_Max
  0     Male   40     40
  1     Male   22     40
  2     Male   23     40
  3   Female   55     75
  4   Female   75     75
  5   Female   31     75
  6     Male   22     26
  7     Male   23     26
  8     Male   26     26
  9   Female   29     40
  10  Female   33     40
  11  Female   32     40
  12  Female   40     40
  13    Male   41     47
  14    Male   47     54
  15  Female   48     54
  16  Female   54     54
  </code></pre>
  <p>I am not looking for following output, as I want cummax reset every time when gender type changes</p>
  <pre><code>df[&quot;cumsum&quot;] = df.groupby(['Type']).Age.cummax()
  
        Type  Age  cumsum
  0     Male   40      40
  1     Male   22      40
  2     Male   23      40
  3   Female   55      55
  4   Female   75      75
  5   Female   31      75
  6     Male   22      40
  7     Male   23      40
  8     Male   26      40
  9   Female   29      75
  10  Female   33      75
  11  Female   32      75
  12  Female   40      75
  13    Male   41      41
  14    Male   47      47
  15  Female   48      75
  16  Female   54      75
  </code></pre>