title: pandas merge with condition
body: <p>I have two dataframe and want to merge it based on max of another column</p>
  
  <pre><code>df1:
  C2
  A
  B
  C
  
  df2:
  C1 C2 val
  X  A  100
  Y  A  50.5
  Z  A  60
  E  B  90
  F  B  45
  G  C  100
  </code></pre>
  
  <p>I tried, </p>
  
  <pre><code>df3 = df1.merge(df2, on='C2', how='inner')['val'].max()
  </code></pre>
  
  <p>I get the error, <code>AttributeError: 'numpy.float64' object has no attribute 'head'</code></p>
  
  <p>The val column has only numbers. How should I modify this and Why do I encounter this error ?</p>
  
  <p>The expected output is:</p>
  
  <pre><code>df3:
  C2 C1 val
  A  X  100
  B  E  90
  C  G  100
  </code></pre>
  
  <p>Thanks in advance.</p>