title: How to create a pivot table in python (pandas)
body: <p>I have a table like this:</p>
  
  <p><strong>train_df:</strong> </p>
  
  <pre><code>Sex Target
  M   1
  M   1
  M   1
  F   0
  F   1
  F   0
  </code></pre>
  
  <p>I want to create a pivot chart, so that it can show result some thing like this:</p>
  
  <pre><code>Row Labels  Average of Target
     F              0.333333333
     M                   1
  </code></pre>
  
  <p>I have written a code like this:</p>
  
  <pre><code>temp2 = train_df.pivot_table(values='Target', index=['Sex'],aggfunc=lambda x: x.map.mean().
  </code></pre>
  
  <p>I am getting errored out as "AttributeError: 'function' object has no attribute 'mean'". I know that the usage is not correct in the map.mean function. Could you please help me how to eradicate this. Thank you.</p>