title: Python Dataframe GroupBy Function
body: <p>I am having hard time understanding what the code below does. I initially thought it was counting the unique appearances of the values in (weight age) and (weight height) however when I ran this example, I found out it was doing something else.</p>
  <pre><code>data = [[0,33,15,4],[1,44,12,3],[0,44,12,5],[1,33,15,4],[0,77,13,4],[1,33,15,4],[1,99,40,7],[0,58,45,4],[1,11,13,4]]
  df = pd.DataFrame(data,columns=[&quot;Lbl&quot;,&quot;Weight&quot;,&quot;Age&quot;,&quot;Height&quot;])
  print (df)
  
  def group_fea(df,key,target):
      '''
      Adds columns for feature combinations
      '''
      tmp = df.groupby(key, as_index=False)[target].agg({
          key+target + '_nunique': 'nunique',
      }).reset_index()
      del tmp['index']
      print(&quot;****{}****&quot;.format(target))
      return tmp
  
  
  #Add feature combinations
  feature_key = ['Weight']
  feature_target = ['Age','Height']
  for key in feature_key:
      for target in feature_target:
          tmp = group_fea(df,key,target)
          df = df.merge(tmp,on=key,how='left')
  
  print (df) 
        Lbl  Weight  Age  Height
  0    0      33   15       4
  1    1      44   12       3
  2    0      44   12       5
  3    1      33   15       4
  4    0      77   13       4
  5    1      33   15       4
  6    1      99   40       7
  7    0      58   45       4
  8    1      11   13       4
  ****Age****
  ****Height****
     Lbl  Weight  Age  Height  WeightAge_nunique  WeightHeight_nunique
  0    0      33   15       4                  1                     1
  1    1      44   12       3                  1                     2
  2    0      44   12       5                  1                     2
  3    1      33   15       4                  1                     1
  4    0      77   13       4                  1                     1
  5    1      33   15       4                  1                     1
  6    1      99   40       7                  1                     1
  7    0      58   45       4                  1                     1
  8    1      11   13       4                  1                     1
  </code></pre>
  <p>I want to understand what the values in WeightAge_nunique  WeightHeight_nunique mean</p>