title: replace values of one column in a spark df by dictionary key-values (pyspark)
body: <p>I got stucked with a data transformation task in pyspark.
  I want to replace all values of one column in a df with key-value-pairs specified in a dictionary.</p>
  
  <pre><code>dict = {'A':1, 'B':2, 'C':3}
  </code></pre>
  
  <p>My df looks like this:</p>
  
  <pre><code>+-----------++-----------+
  |       col1||       col2|
  +-----------++-----------+
  |          B||          A|
  |          A||          A|
  |          A||          A|
  |          C||          B|
  |          A||          A|
  +-----------++-----------+
  </code></pre>
  
  <p>Now I want to replace all values of col1 by the key-values pairs defined in dict. </p>
  
  <p>Desired Output:</p>
  
  <pre><code>+-----------++-----------+
  |       col1||       col2|
  +-----------++-----------+
  |          2||          A|
  |          1||          A|
  |          1||          A|
  |          3||          B|
  |          1||          A|
  +-----------++-----------+
  </code></pre>
  
  <p>I tried </p>
  
  <pre><code>df.na.replace(dict, 1).show()
  </code></pre>
  
  <p>but that also replaces the values on col2, which shall stay untouched.</p>
  
  <p>Thank you for your help.
  Greetings :)</p>