title: TypeError: 'fill_value= xx ' is not present in this Categorical's categories
body: <p>I used <code>groupby</code> and <code>unstack</code> to create a data frame and want to create a new column for subscription ratio.</p>
  <pre><code>df_sub = df.groupby(['time_section', 'day_type', 'user_type']).size().unstack()
  df_sub['ratio'] = df_sub['Subscriber'] / df_sub['Customer']
  </code></pre>
  <p>And it turns out the error &quot;TypeError: 'fill_value=ratio' is not present in this Categorical's categories&quot;</p>
  <p>Could someone help me?</p>
  <pre><code>---------------------------------------------------------------------------
  KeyError                                  Traceback (most recent call last)
  /opt/anaconda3/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
     3079             try:
  -&gt; 3080                 return self._engine.get_loc(casted_key)
     3081             except KeyError as err:
  
  pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
  
  pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
  
  pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
  
  pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
  
  KeyError: 'ratio'
  
  The above exception was the direct cause of the following exception:
  
  KeyError                                  Traceback (most recent call last)
  /opt/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py in _set_item(self, key, value)
     3825         try:
  -&gt; 3826             loc = self._info_axis.get_loc(key)
     3827         except KeyError:
  
  /opt/anaconda3/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
     3077                 )
  -&gt; 3078             casted_key = self._maybe_cast_indexer(key)
     3079             try:
  
  /opt/anaconda3/lib/python3.8/site-packages/pandas/core/indexes/category.py in _maybe_cast_indexer(self, key)
      495     def _maybe_cast_indexer(self, key) -&gt; int:
  --&gt; 496         return self._data._unbox_scalar(key)
      497 
  
  /opt/anaconda3/lib/python3.8/site-packages/pandas/core/arrays/categorical.py in _unbox_scalar(self, key)
     1720         # to same dtype as self.codes, we get much faster performance.
  -&gt; 1721         code = self.categories.get_loc(key)
     1722         code = self._codes.dtype.type(code)
  
  /opt/anaconda3/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
     3081             except KeyError as err:
  -&gt; 3082                 raise KeyError(key) from err
     3083 
  
  KeyError: 'ratio'
  
  During handling of the above exception, another exception occurred:
  
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-80-ef99a6bd1acd&gt; in &lt;module&gt;
  ----&gt; 1 df_sub['ratio'] = df_sub['Subscriber'] / df_sub['Customer']
  
  /opt/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py in __setitem__(self, key, value)
     3161         else:
     3162             # set column
  -&gt; 3163             self._set_item(key, value)
     3164 
     3165     def _setitem_slice(self, key: slice, value):
  
  /opt/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py in _set_item(self, key, value)
     3241         self._ensure_valid_index(value)
     3242         value = self._sanitize_column(key, value)
  -&gt; 3243         NDFrame._set_item(self, key, value)
     3244 
     3245         # check if we are modifying a copy
  
  /opt/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py in _set_item(self, key, value)
     3827         except KeyError:
     3828             # This item wasn't present, just insert at end
  -&gt; 3829             self._mgr.insert(len(self._info_axis), key, value)
     3830             return
     3831 
  
  /opt/anaconda3/lib/python3.8/site-packages/pandas/core/internals/managers.py in insert(self, loc, item, value, allow_duplicates)
     1195 
     1196         # insert to the axis; this could possibly raise a TypeError
  -&gt; 1197         new_axis = self.items.insert(loc, item)
     1198 
     1199         if value.ndim == self.ndim - 1 and not is_extension_array_dtype(value.dtype):
  
  /opt/anaconda3/lib/python3.8/site-packages/pandas/core/indexes/extension.py in insert(self, loc, item)
      377         &quot;&quot;&quot;
      378         arr = self._data
  --&gt; 379         code = arr._validate_scalar(item)
      380 
      381         new_vals = np.concatenate((arr._ndarray[:loc], [code], arr._ndarray[loc:]))
  
  /opt/anaconda3/lib/python3.8/site-packages/pandas/core/arrays/categorical.py in _validate_fill_value(self, fill_value)
     1249             fill_value = self._unbox_scalar(fill_value)
     1250         else:
  -&gt; 1251             raise TypeError(
     1252                 f&quot;'fill_value={fill_value}' is not present &quot;
     1253                 &quot;in this Categorical's categories&quot;
  
  TypeError: 'fill_value=ratio' is not present in this Categorical's categories
  </code></pre>
  <p><a href="https://i.stack.imgur.com/KXHYa.png." rel="nofollow noreferrer">data frame</a></p>
  <pre><code>df_sub.index
  MultiIndex([('10am-12pm', 'weekday'),
              ('10am-12pm', 'weekend'),
              ('10pm-12am', 'weekday'),
              ('10pm-12am', 'weekend'),
              (  '1am-3am', 'weekday'),
              (  '1am-3am', 'weekend'),
              (  '1pm-3pm', 'weekday'),
              (  '1pm-3pm', 'weekend'),
              (  '4am-6am', 'weekday'),
              (  '4am-6am', 'weekend'),
              (  '4pm-6pm', 'weekday'),
              (  '4pm-6pm', 'weekend'),
              (  '7am-9am', 'weekday'),
              (  '7am-9am', 'weekend'),
              (  '7pm-9pm', 'weekday'),
              (  '7pm-9pm', 'weekend')],
             names=['time_section', 'day_type'])
  df_sub.columns
  CategoricalIndex(['Customer', 'Subscriber'], categories=['Customer', 'Subscriber'], ordered=False, name='user_type', dtype='category')
  </code></pre>