title: Imputing data results in ValueError: Length of replacements must equal series length
body: <p>I have a data frame with the following columns</p>
  <pre><code>missing_df.columns.tolist()
  </code></pre>
  <p>which returns a list:</p>
  <pre><code>   ['order_id',
       'customer_id',
       'date',
       'nearest_warehouse',
       'shopping_cart',
       'order_price',
       'delivery_charges',
       'customer_lat',
       'customer_long',
       'coupon_discount',
       'order_total',
       'season',
       'is_expedited_delivery',
       'distance_to_nearest_warehouse',
       'latest_customer_review',
       'is_happy_customer',
       'Autumn',
       'Spring',
       'Summer',
       'Winter',
       'exp_int']
  </code></pre>
  <p>if i try to run the following operation</p>
  <pre><code>missing_df['delivery_charges'][missing_df['delivery_charges'].isnull()] = iimput_model.predict(missing_df.drop(['order_id','customer_id','date','nearest_warehouse','shopping_cart','order_price','delivery_charges','customer_lat','customer_long','coupon_discount','order_total','season','is_expedited_delivery','latest_customer_review'],1))
  </code></pre>
  <p>I get the following error:</p>
  <pre><code>---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  ~\AppData\Roaming\Python\Python37\site-packages\pandas\core\series.py in __setitem__(self, key, value)
      999         try:
  -&gt; 1000             self._set_with_engine(key, value)
     1001         except (KeyError, ValueError):
  
  ~\AppData\Roaming\Python\Python37\site-packages\pandas\core\series.py in _set_with_engine(self, key, value)
     1032         # fails with AttributeError for IntervalIndex
  -&gt; 1033         loc = self.index._engine.get_loc(key)
     1034         validate_numeric_casting(self.dtype, value)
  
  pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
  
  pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
  
  TypeError: '0      False
  1      False
  2      False
  3       True
  4      False
         ...  
  495    False
  496    False
  497    False
  498    False
  499    False
  Name: delivery_charges, Length: 500, dtype: bool' is an invalid key
  
  During handling of the above exception, another exception occurred:
  
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-418-60aee038ac4a&gt; in &lt;module&gt;
        1 #dirty_df.reindex(columns=filtered_columns)
        2 #missing_df['delivery_charges'][missing_df['delivery_charges'].isnull()] = iimput_model.predict(missing_df.drop(['order_id','customer_id','date','nearest_warehouse','shopping_cart','order_price','delivery_charges','customer_lat','customer_long','coupon_discount','order_total','season','is_expedited_delivery','latest_customer_review'],1))
  ----&gt; 3 missing_df['delivery_charges'][missing_df['delivery_charges'].isnull()] = iimput_model.predict(missing_df.reindex(columns=filter_cols))
  
  ~\AppData\Roaming\Python\Python37\site-packages\pandas\core\series.py in __setitem__(self, key, value)
     1018                 key = np.asarray(key, dtype=bool)
     1019                 try:
  -&gt; 1020                     self._where(~key, value, inplace=True)
     1021                 except InvalidIndexError:
     1022                     self.iloc[key] = value
  
  ~\AppData\Roaming\Python\Python37\site-packages\pandas\core\generic.py in _where(self, cond, other, inplace, axis, level, errors, try_cast)
     8820                     else:
     8821                         raise ValueError(
  -&gt; 8822                             &quot;Length of replacements must equal series length&quot;
     8823                         )
     8824 
  
  ValueError: Length of replacements must equal series length
  </code></pre>
  <p>Can somebody please explain this error and how to resolve it, I have spent a bit of time on this and keep coming up short</p>
  <p>Thanks for any advice or input</p>