title: Pandas: re-index and interpolate in multi-index dataframe
body: <p>I'm having trouble understanding pandas <code>reindex</code>. I have a series of measurements, munged into a multi-index <code>df</code>, and I'd like to reindex and interpolate those measurements to align them with some other data.</p>
  
  <p>My actual data has ~7 index levels and several different measurements. I hope the solution for this toy data problem is applicable to my real data. It's "small data"; each individual measurement is a couple KB.</p>
  
  <p>Here's a pair of toy problems, one which shows the expected behavior and one which doesn't seem to do anything.</p>
  
  <p>Single-level index, works as expected:</p>
  
  <pre><code>"""
  step,value
  1,1
  3,2
  5,1
  """
  df_i = pd.read_clipboard(sep=",").set_index("step")
  print(df_i)
  
  new_index = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9])
  
  df_i = df_i.reindex(new_index).interpolate()
  print(df_i)
  </code></pre>
  
  <p>Outputs, the original df and the re-indexed and interpolated one:</p>
  
  <pre><code>      value
  step       
  1         1
  3         2
  5         1
        value
  step       
  1       1.0
  2       1.5
  3       2.0
  4       1.5
  5       1.0
  6       1.0
  7       1.0
  8       1.0
  9       1.0
  </code></pre>
  
  <p>Works great.</p>
  
  <p>Multi-index, currently not working:</p>
  
  <pre><code>"""
  sample,meas_id,step,value
  1,1,1,1
  1,1,3,2
  1,1,5,1
  1,2,3,2
  1,2,5,2
  1,2,7,1
  1,2,9,0
  """
  df_mi = pd.read_clipboard(sep=",").set_index(["sample", "meas_id", "step"])
  print(df_mi)
  
  df_mi = df_mi.reindex(new_index, level="step").interpolate()
  print(df_mi)
  </code></pre>
  
  <p>Output, unchanged after reindex (and therefore after interpolate):</p>
  
  <pre><code>                     value
  sample meas_id step       
  1      1       1         1
                 3         2
                 5         1
         2       3         2
                 5         2
                 7         1
                 9         0
  
  
                       value
  sample meas_id step       
  1      1       1         1
                 3         2
                 5         1
         2       3         2
                 5         2
                 7         1
                 9         0
  </code></pre>
  
  <p>How do I <em>actually</em> reindex a column in a multi-index df?</p>
  
  <p>Here's the output I'd like, assuming linear interpolation:</p>
  
  <pre><code>                     value
  sample meas_id step       
  1      1       1         1
                 2       1.5
                 3         2
                 5         1
                 6         1
                 7         1
                 8         1
                 9         1
         2       1       NaN (or 2)
                 2       NaN (or 2)
                 3         2
                 4         2
                 5         2
                 6       1.5
                 7         1
                 8       0.5
                 9         0
  </code></pre>
  
  <p>I spent some sincere time looking over SO, and if the answer is in there, I missed it:</p>
  
  <p><a href="https://stackoverflow.com/questions/27640202/fill-multi-index-pandas-dataframe-with-interpolation/27657638">Fill multi-index Pandas DataFrame with interpolation</a></p>
  
  <p><a href="https://stackoverflow.com/questions/15799162/resampling-within-a-pandas-multiindex">Resampling Within a Pandas MultiIndex</a></p>
  
  <p><a href="https://stackoverflow.com/questions/29465398/pandas-multiindex-dataframe-nd-interpolation-for-missing-values">pandas multiindex dataframe, ND interpolation for missing values</a></p>
  
  <p><a href="https://stackoverflow.com/questions/27640202/fill-multi-index-pandas-dataframe-with-interpolation">Fill multi-index Pandas DataFrame with interpolation</a></p>
  
  <p><a href="https://pandas.pydata.org/pandas-docs/stable/basics.html#basics-reindexing" rel="nofollow noreferrer">https://pandas.pydata.org/pandas-docs/stable/basics.html#basics-reindexing</a></p>
  
  <p>Possibly related GitHub issues:</p>
  
  <p><a href="https://github.com/numpy/numpy/issues/11975" rel="nofollow noreferrer">https://github.com/numpy/numpy/issues/11975</a></p>
  
  <p><a href="https://github.com/pandas-dev/pandas/issues/23104" rel="nofollow noreferrer">https://github.com/pandas-dev/pandas/issues/23104</a></p>
  
  <p><a href="https://github.com/pandas-dev/pandas/issues/17132" rel="nofollow noreferrer">https://github.com/pandas-dev/pandas/issues/17132</a></p>