title: Pandas — set values using partial slicing on MultiIndex
body: <p>I have this bit of code, which produces the following empty DataFrame:</p>
  
  <pre><code>&gt;&gt;&gt; first = ['foo', 'bar']
  &gt;&gt;&gt; second = ['baz', 'can']
  &gt;&gt;&gt; third = ['ok', 'ko']
  &gt;&gt;&gt; colours = ['blue', 'yellow', 'green']
  
  &gt;&gt;&gt; idx = pd.IndexSlice
  &gt;&gt;&gt; ix = pd.MultiIndex.from_arrays(np.array([i for i in itertools.product(first, second, third)]).transpose().tolist(),
                                     names=('first', 'second', 'third'))
  &gt;&gt;&gt; df1 = pd.DataFrame(index=ix, columns=colours).sort_index()
  &gt;&gt;&gt; print(df1)
  
                     blue yellow green
  first second third                  
  bar   baz    ko     NaN    NaN   NaN
               ok     NaN    NaN   NaN
        can    ko     NaN    NaN   NaN
               ok     NaN    NaN   NaN
  foo   baz    ko     NaN    NaN   NaN
               ok     NaN    NaN   NaN
        can    ko     NaN    NaN   NaN
               ok     NaN    NaN   NaN
  </code></pre>
  
  <p>What I intend to do, is populate this MultiIndex-based empty DataFrame from another DataFrame that is given and which is column-based, like the following (columns truncated for clarity):</p>
  
  <pre><code>     baz_ok_blue  baz_ko_blue  can_ok_blue  can_ko_blue  baz_ok_yellow
  foo    -1.385111    -1.014812    -1.419643     1.540341       0.663933
  bar     0.445372    -0.226087     0.450982    -1.114169       0.896522
  </code></pre>
  
  <p>So far I've been trying this way:</p>
  
  <pre><code>idx = pd.IndexSlice
  for s in second:
      for t in third:
          for c in colours:
              column_name = '{s}_{t}_{c}'.format(s=s, c=c, t=t)
              values = df2[column_name]
              df1.loc[idx[:, s, t], c] = values
  </code></pre>
  
  <p>In each iteration, the <code>values</code> Series is correctly determined, however Pandas doesn't match the index of <code>values</code> with the first level of df1's MultiIndex. As a result, all df1 values stay <code>NaN</code>, because Pandas is trying to match a MultiIndex with a single Index. Is there a way out of this?</p>
  
  <p>Basically, to give a higher-level perspective, I'm simply trying to rearrange df2 (string-columns based) into the form of df1 (MultiIndex based).</p>