title: How to properly understand pandas dataframe merge (how, left_on, right_on)?
body: <p>I have been trying to wrap my head around <code>merge</code> for a while:</p>
  
  <p>I have the following dataframes:</p>
  
  <pre><code>staff_df = pd.DataFrame([{'Name': 'Kelly', 'Role': 'Director of HR', 'Location': 'State Street'},
                           {'Name': 'Sally', 'Role': 'Course liasion', 'Location': 'Washington Avenue'},
                           {'Name': 'James', 'Role': 'Grader', 'Location': 'Washington Avenue'}])
  student_df = pd.DataFrame([{'Name': 'James', 'School': 'Business', 'Location': '1024 Billiard Avenue'},
                             {'Name': 'Mike', 'School': 'Law', 'Location': 'Fraternity House #22'},
                             {'Name': 'Sally', 'School': 'Engineering', 'Location': '512 Wilson Crescent'}])
  </code></pre>
  
  <p>I understand that I can merge them in more ways than one:</p>
  
  <pre><code>pd.merge(staff_df, student_df, how='left', left_on='Name', right_on='Name')
  pd.merge(student_df, staff_df, how='left', left_on='Name', right_on='Name')
  pd.merge(staff_df, student_df, how='right', left_on='Name', right_on='Name')
  pd.merge(student_df, staff_df, how='right', left_on='Name', right_on='Name')
  </code></pre>
  
  <p>Each produces a slightly different output. Can someone guide me on the proper way to understand how each output is constructed?</p>
  
  <p>Specifically,</p>
  
  <ul>
  <li>Why are the role and school columns always between location_y? </li>
  <li>When is the role column beside the name column and when is the school
  column beside the name column?</li>
  </ul>
  
  <p>I would hold off asking about using <code>left_index</code> and <code>right_on</code> in the same merge statement.</p>
  
  <p>Thanks.</p>