title: How to encode a categorical variable (series) in the data frame in Python?
body: <p>I have a dictionary of the following form:</p>
  
  <pre><code>{CA: California, NV: Nevada, TX: Texas}
  </code></pre>
  
  <p>I want to transform my data frame </p>
  
  <pre><code>{
   'state':['California', 'California, 'Texas', 'Nevada', 'Texas],
   'var':[100,200,300,400, 500]
  }
  </code></pre>
  
  <p>into</p>
  
  <pre><code>{
   'state':['CA','CA','TX','NV','TX'],
   'var':[100,200,300,400,500]
  }
  </code></pre>
  
  <p>What's the best way to do this?</p>