title: Using apply to the pandas group object with original function
body: <p>I have a multi-index df and I want to add a new column by apply an operation</p>
  <pre><code>class weight  height  time
  A       45     150    85
          50     160    80
          55     155    74
  B       78     180    90
          51     158    65
          40     155    68
  C       80     185    90
          86     175    81
          52     162    73
  
  def operation(col):
      concat = ''
      for i in col:
          concat += (str(i))
      return concat
  </code></pre>
  <p>and the result df should look like</p>
  <pre><code>df['new'] = df.groupby(level=0)['height'].apply(operation)
  
  class weight  height  time new
  A       45     150    85   150160155
          50     160    80
          55     155    74
  B       78     180    90   180158155
          51     158    65
          40     155    68
  C       80     185    90   185175162
          86     175    81
          52     162    73
  </code></pre>
  <p>However, the resultant df actually add <code>NaN</code> to new column. What am I doing wrong?</p>