title: pd.Categorical.from_codes with missing values
body: <p>Assume I have:</p>
  
  <pre><code>df = pd.DataFrame({'gender': np.random.choice([1, 2], 10), 'height': np.random.randint(150, 210, 10)})
  </code></pre>
  
  <p>I'd like to make the gender column categorical. If I try:</p>
  
  <pre><code>df['gender'] = pd.Categorical.from_codes(df['gender'], ['female', 'male'])
  </code></pre>
  
  <p>it'll fail.</p>
  
  <p>I can pad the categories</p>
  
  <pre><code>df['gender'] = pd.Categorical.from_codes(df['gender'], ['N/A', 'female', 'male'])
  </code></pre>
  
  <p>But then <code>'N/A'</code> is returned in some methods:</p>
  
  <pre><code>In [67]: df['gender'].value_counts()
  Out[67]: 
  female    5
  male      5
  N/A       0
  Name: gender, dtype: int64
  </code></pre>
  
  <p>I thought about using <code>None</code> as the padding value. It works as intended in the <code>value_counts</code> however I get a warning:</p>
  
  <pre><code>opt/anaconda3/bin/ipython:1: FutureWarning: 
  Setting NaNs in `categories` is deprecated and will be removed in a future version of pandas.
    #!/opt/anaconda3/bin/python
  </code></pre>
  
  <p>Any better way to do this? Also is there a way to give a mapping from code to category explicitly?</p>