title: Error while converting categorical feature to numerical feature in Pandas
body: <p>My dataframe contains a categorical feature 'Street' which can take 1 of the 2 possible values 'Grvl' or 'Pave'. I am trying to convert this categorical feature in to numerical value before fitting ML algorithm. My code looks like this</p>
  
  <pre><code>dataset['Street']=dataset['Street'].map({'Grvl':0,'Pave':1}).astype(int)
  </code></pre>
  
  <p>I have filled missing values with the most occurring value in the dataframe</p>
  
  <pre><code>dataset['Street'].isnull().sum()
  </code></pre>
  
  <p>I am getting following error</p>
  
  <pre><code>    ValueError                                Traceback (most recent call last)
  &lt;ipython-input-59-86f0b031335a&gt; in &lt;module&gt;()
        2     print dataset['Street'].isnull().sum()
        3     #dataset['MSZoning'] = dataset['MSZoning'].map( {'A': 0, 'C': 1,'FV': 2,'I':3,'RH':4,'RL':5,'RP':6,'RM':7} ).astype(int)
  ----&gt; 4     dataset['Street']=dataset['Street'].map({'Grvl':0,'Pave':1}).astype(int)
        5     dataset['LotShape']=dataset['LotShape'].map({'Reg':0,'IR1':1,'IR2':2,'IR3':3}).astype(int)
        6     dataset['LandContour']=dataset['LandContour'].map({'Lvl':0,'Bnk':1,'HLS':2,'Low':3}).astype(int)
  
  C:\Users\JAYASHREE\Anaconda2\lib\site-packages\pandas\core\generic.pyc in astype(self, dtype, copy, raise_on_error, **kwargs)
     2948 
     2949         mgr = self._data.astype(dtype=dtype, copy=copy,
  -&gt; 2950                                 raise_on_error=raise_on_error, **kwargs)
     2951         return self._constructor(mgr).__finalize__(self)
     2952 
  
  C:\Users\JAYASHREE\Anaconda2\lib\site-packages\pandas\core\internals.pyc in astype(self, dtype, **kwargs)
     2936 
     2937     def astype(self, dtype, **kwargs):
  -&gt; 2938         return self.apply('astype', dtype=dtype, **kwargs)
     2939 
     2940     def convert(self, **kwargs):
  
  C:\Users\JAYASHREE\Anaconda2\lib\site-packages\pandas\core\internals.pyc in apply(self, f, axes, filter, do_integrity_check, consolidate, raw, **kwargs)
     2888 
     2889             kwargs['mgr'] = self
  -&gt; 2890             applied = getattr(b, f)(**kwargs)
     2891             result_blocks = _extend_blocks(applied, result_blocks)
     2892 
  
  C:\Users\JAYASHREE\Anaconda2\lib\site-packages\pandas\core\internals.pyc in astype(self, dtype, copy, raise_on_error, values, **kwargs)
      432                **kwargs):
      433         return self._astype(dtype, copy=copy, raise_on_error=raise_on_error,
  --&gt; 434                             values=values, **kwargs)
      435 
      436     def _astype(self, dtype, copy=False, raise_on_error=True, values=None,
  
  C:\Users\JAYASHREE\Anaconda2\lib\site-packages\pandas\core\internals.pyc in _astype(self, dtype, copy, raise_on_error, values, klass, mgr, **kwargs)
      475 
      476                 # _astype_nansafe works fine with 1-d only
  --&gt; 477                 values = com._astype_nansafe(values.ravel(), dtype, copy=True)
      478                 values = values.reshape(self.shape)
      479 
  
  C:\Users\JAYASHREE\Anaconda2\lib\site-packages\pandas\core\common.pyc in _astype_nansafe(arr, dtype, copy)
     1912 
     1913         if np.isnan(arr).any():
  -&gt; 1914             raise ValueError('Cannot convert NA to integer')
     1915     elif arr.dtype == np.object_ and np.issubdtype(dtype.type, np.integer):
     1916         # work around NumPy brokenness, #1987
  
  ValueError: Cannot convert NA to integer
  </code></pre>