title: Using pandas .map to change values
body: <p>I'm trying to change the strings in my data do numerical value using map function.</p>
  
  <p>This is the data:</p>
  
  <pre><code>    label   sms_message
  0   ham     Go until jurong point, crazy.. Available only ...
  1   ham     Ok lar... Joking wif u oni...
  2   spam    Free entry in 2 a wkly comp to win FA Cup fina...
  3   ham     U dun say so early hor... U c already then say...
  4   ham     Nah I don't think he goes to usf, he lives aro...
  </code></pre>
  
  <p>I'm trying to change 'spam' to 1 and 'ham' to 0 using this:</p>
  
  <pre><code>df['label'] = df.label.map({'ham':0, 'spam':1})
  </code></pre>
  
  <p>But the result is:</p>
  
  <pre><code>    label   sms_message
  0   NaN     Go until jurong point, crazy.. Available only ...
  1   NaN     Ok lar... Joking wif u oni...
  2   NaN     Free entry in 2 a wkly comp to win FA Cup fina...
  3   NaN     U dun say so early hor... U c already then say...
  4   NaN     Nah I don't think he goes to usf, he lives aro...
  </code></pre>
  
  <p>Do anyone can identify the problem?</p>