title: how to sort a dataframe according to another dataframe column values?
body: <p>I have two data frames df1 and df2</p>
  <pre><code>df1 = pd.dataframe(&quot;TestCaseName&quot; : ['B', 'D', 'A', 'E', 'C'])
  
    TestCaseName
  0     B
  1     D
  2     A
  3     E
  4     C
  </code></pre>
  <p>and another data frame</p>
  <pre><code>df2 = pd.dataframe({&quot;TestCaseName&quot; : ['A', 'B', 'C', 'D', 'E'], &quot;NameSpace&quot; : ['T2'. 'T3', 'T6', 'T1', 'T8'])
  
     TestCaseName  NameSpace    
  
   0      A           T2
   1      B           T3
   2      C           T6
   3      D           T1
   4      E           T8
  </code></pre>
  <p>What i want is sort the test case name of df2 according to df1.</p>
  <p>Here is what i have tried;</p>
  <pre><code>df2 = df2.set_index('TestCaseName')
  df2 = df2.reindex(index=df1['TestCaseName'])
  df2 = df2.reset_index()
  </code></pre>
  <p>Which is giving me error ValueError: cannot reindex from a duplicate axis</p>
  <p>Desired Output:</p>
  <pre><code>  TestCaseName NameSpace
  0     B           T3
  1     D           T1 
  2     A           T2
  3     E           T8
  4     C           T6
  </code></pre>
  <p>Can someone tell me what am i doing wrong or suggest any better idea?</p>