title: Replacing a string by an integer dictionary in python pandas dataframe
body: <p>I have the following pandas dataframe.  </p>
  
  <pre><code>        epi_week    state   loc_type    disease    cases    incidence
  21835   200011      WY      STATE       MUMPS       2       0.40
  21836   197501      WY      STATE       POLIO       3       0.76
  21837   199607      WY      STATE       HEPATITIS   3       0.61
  21838   197116      WY      STATE       MUMPS       6       1.73
  21839   200048      WY      STATE       HEPATITIS   6       1.21
  </code></pre>
  
  <p>I am trying to replace each <code>disease</code> by a unique integer. For example <code>'MUMPS'==1</code>, <code>'POLIO'==2</code> etc. The final dataframe should look like follows:</p>
  
  <pre><code>        epi_week    state   loc_type    disease    cases    incidence
  21835   200011      WY      STATE       1          2        0.40
  21836   197501      WY      STATE       2          3        0.76
  21837   199607      WY      STATE       3          3        0.61
  21838   197116      WY      STATE       1          6        1.73
  21839   200048      WY      STATE       3          6        1.21
  </code></pre>
  
  <p>I am using the following code:</p>
  
  <pre><code># creating a dictionary     
  disease_dic = {'MUMPS':1, 'POLIO':2, 'MEASLES':3, 'RUBELLA':4,
                 'PERTUSSIS':5, 'HEPATITIS A':6, 'SMALLPOX':7, 
                 'DIPHTHERIA':8}
  data.disease = [disease_dic[item] for item in data.disease]
  </code></pre>
  
  <p>I am getting following errors:</p>
  
  <pre><code>KeyErrorTraceback (most recent call last)
  &lt;ipython-input-115-52394901c90d&gt; in &lt;module&gt;()
  ----&gt; 1 cdc.disease = [disease_dic[item2] for item2 in cdc.disease]
  
  KeyError: 1
  </code></pre>
  
  <p>Can anyone please help about this issue? Thank you.</p>