title: pandas multiindex assignment from another dataframe
body: <p>I am trying to understand <code>pandas</code> <code>MultiIndex</code> <code>DataFrame</code>s and how to assign data to them. Specifically I'm interested in assigning entire blocks that match another smaller data frame.</p>
  
  <pre><code>ix = pd.MultiIndex.from_product([['A', 'B'], ['a', 'b', 'c', 'd']])
  df = pd.DataFrame(index=ix, columns=['1st', '2nd', '3rd'], dtype=np.float64)
  df_ = pd.DataFrame(index=['a', 'b', 'c', 'd'], columns=['1st', '2nd', '3rd'], data=np.random.rand(4, 3))
  df_
  
      1st     2nd     3rd
  a   0.730251    0.468134    0.876926
  b   0.104990    0.082461    0.129083
  c   0.993608    0.117799    0.341811
  d   0.784950    0.840145    0.016777
  </code></pre>
  
  <p><code>df</code> is the same except that all the values are <code>NaN</code> and there are two blocks <code>A</code> and <code>B</code>. Now if I want to assign the values from <code>df_</code> to <code>df</code> I would imagine I can do something like</p>
  
  <pre><code>df.loc['A',:] = df_                # Runs, does not work
  df.loc[('A','a'):('A','d')] = df_  # AssertionError (??) 'Start slice bound is non-scalar'
  df.loc[('A','a'):('A','d')]        # No AssertionError (??)
  
  idx = pd.IndexSlice
  df.loc[idx['A', :]] = df_          # Runs, does not work
  </code></pre>
  
  <p>None of these work, they leave all the values in <code>df</code> as <code>NaN</code>, although <code>df.loc[idx['A', :]]</code> gives me a slice of the data frame that exactly matches that of the sub frame (<code>df_</code>). So is this a case of setting values on a view? Explicitly iterating over the index in <code>df_</code> works</p>
  
  <pre><code># this is fine
  for v in df_.index:
      df.loc[idx['A', v]] = df_.loc[v]
  
  # this is also fine
  for v in df_.index:
      df.loc['A', v] = df_.loc[v]
  </code></pre>
  
  <p>Is it even possible to assign whole blocks like this (sort of like <code>NumPy</code>)? If not, that's fine, I am simply trying to understand how the system works.</p>
  
  <p>There's a related question about index slicers, but it's about assigning a single value to a masked portion of the <code>DataFrame</code>, not about assigning blocks.
  <a href="https://stackoverflow.com/questions/28002197/pandas-proper-way-to-set-values-based-on-condition-for-subset-of-multiindex-da">Pandas : Proper way to set values based on condition for subset of multiindex dataframe</a></p>