title: How to update multiple entries of a certain column of a Pandas dataframe in certain order?
body: <p>Let’s say I have the following Pandas dataframe, where the <code>'key'</code> column only contains unique strings:</p>
  <pre><code>import pandas as pd
  df = pd.DataFrame({'key':['b','d','c','a','e','f'], 'value': [0,0,0,0,0,0]})
  df
  
    key value
  0   b     0
  1   d     0
  2   c     0
  3   a     0
  4   e     0
  5   f     0
  </code></pre>
  <p>Now I have a list of unique keys and a list of corresponding values:</p>
  <pre><code>keys = ['a', 'b', 'c', 'd']
  values = [1, 2, 3, 4]
  </code></pre>
  <p>I want to update the <code>'value'</code> column in the same order of the lists, so that each row has matched <code>'key'</code> and <code>'value'</code> (<code>a</code> to <code>1</code>, <code>'b'</code> to <code>2</code>, <code>'c'</code> to <code>3</code>, <code>'d'</code> to <code>4</code>). I am using the following code, but the dataframe seems to update values from top to bottom, which I don't quite understand</p>
  <pre><code>df.loc[df['key'].isin(keys),'value'] = values
  df
  
    key value
  0   b     1
  1   d     2
  2   c     3
  3   a     4
  4   e     0
  5   f     0
  </code></pre>
  <p>To be clear, I am expecting to get</p>
  <pre><code>  key value
  0   b     2
  1   d     4
  2   c     3
  3   a     1
  4   e     0
  5   f     0
  </code></pre>
  <p>Any suggestions?</p>