<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from pandas import DataFrame, Timestamp

c = pandas.DataFrame({u'ul_payload': {('a', Timestamp('2016-11-01 06:15:00')): 5, ('a', Timestamp('2016-11-01 07:45:00')): 8, ('a', Timestamp('2016-11-01 09:00:00')): 9, ('a', Timestamp('2016-11-01 07:15:00')): 6, ('a', Timestamp('2016-11-01 07:30:00')): 7, ('a', Timestamp('2016-11-01 06:00:00')): 4}, u'dl_payload': {('a', Timestamp('2016-11-01 06:15:00')): 15, ('a', Timestamp('2016-11-01 07:45:00')): 18, ('a', Timestamp('2016-11-01 09:00:00')): 19, ('a', Timestamp('2016-11-01 07:15:00')): 16, ('a', Timestamp('2016-11-01 07:30:00')): 17, ('a', Timestamp('2016-11-01 06:00:00')): 14}})

In [80]: c
Out[80]:
                       dl_payload  ul_payload
a 2016-11-01 06:00:00          14           4
  2016-11-01 06:15:00          15           5
  2016-11-01 07:15:00          16           6
  2016-11-01 07:30:00          17           7
  2016-11-01 07:45:00          18           8
  2016-11-01 09:00:00          19           9

In [83]: c_fi = pandas.date_range(c.index.get_level_values(1).min(), c.index.get_level_values(1).max(), freq='15Min', name='a')

In [85]: len(c_fi)
Out[85]: 13

In [87]: c.reindex(index=c_fi, level=1).shape
Out[87]: (6, 2)"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">pandas</span> <span class="pl-k">import</span> <span class="pl-v">DataFrame</span>, <span class="pl-v">Timestamp</span>

<span class="pl-s1">c</span> <span class="pl-c1">=</span> <span class="pl-s1">pandas</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">u'ul_payload'</span>: {(<span class="pl-s">'a'</span>, <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-01 06:15:00'</span>)): <span class="pl-c1">5</span>, (<span class="pl-s">'a'</span>, <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-01 07:45:00'</span>)): <span class="pl-c1">8</span>, (<span class="pl-s">'a'</span>, <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-01 09:00:00'</span>)): <span class="pl-c1">9</span>, (<span class="pl-s">'a'</span>, <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-01 07:15:00'</span>)): <span class="pl-c1">6</span>, (<span class="pl-s">'a'</span>, <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-01 07:30:00'</span>)): <span class="pl-c1">7</span>, (<span class="pl-s">'a'</span>, <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-01 06:00:00'</span>)): <span class="pl-c1">4</span>}, <span class="pl-s">u'dl_payload'</span>: {(<span class="pl-s">'a'</span>, <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-01 06:15:00'</span>)): <span class="pl-c1">15</span>, (<span class="pl-s">'a'</span>, <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-01 07:45:00'</span>)): <span class="pl-c1">18</span>, (<span class="pl-s">'a'</span>, <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-01 09:00:00'</span>)): <span class="pl-c1">19</span>, (<span class="pl-s">'a'</span>, <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-01 07:15:00'</span>)): <span class="pl-c1">16</span>, (<span class="pl-s">'a'</span>, <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-01 07:30:00'</span>)): <span class="pl-c1">17</span>, (<span class="pl-s">'a'</span>, <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-01 06:00:00'</span>)): <span class="pl-c1">14</span>}})

<span class="pl-v">In</span> [<span class="pl-c1">80</span>]: <span class="pl-s1">c</span>
<span class="pl-v">Out</span>[<span class="pl-c1">80</span>]:
                       <span class="pl-s1">dl_payload</span>  <span class="pl-s1">ul_payload</span>
<span class="pl-s1">a</span> <span class="pl-c1">2016</span><span class="pl-c1">-</span><span class="pl-c1">11</span><span class="pl-c1">-</span><span class="pl-c1">01</span> <span class="pl-c1">06</span>:<span class="pl-c1">00</span>:<span class="pl-c1">00</span>          <span class="pl-c1">14</span>           <span class="pl-c1">4</span>
  <span class="pl-c1">2016</span><span class="pl-c1">-</span><span class="pl-c1">11</span><span class="pl-c1">-</span><span class="pl-c1">01</span> <span class="pl-c1">06</span>:<span class="pl-c1">15</span>:<span class="pl-c1">00</span>          <span class="pl-c1">15</span>           <span class="pl-c1">5</span>
  <span class="pl-c1">2016</span><span class="pl-c1">-</span><span class="pl-c1">11</span><span class="pl-c1">-</span><span class="pl-c1">01</span> <span class="pl-c1">07</span>:<span class="pl-c1">15</span>:<span class="pl-c1">00</span>          <span class="pl-c1">16</span>           <span class="pl-c1">6</span>
  <span class="pl-c1">2016</span><span class="pl-c1">-</span><span class="pl-c1">11</span><span class="pl-c1">-</span><span class="pl-c1">01</span> <span class="pl-c1">07</span>:<span class="pl-c1">30</span>:<span class="pl-c1">00</span>          <span class="pl-c1">17</span>           <span class="pl-c1">7</span>
  <span class="pl-c1">2016</span><span class="pl-c1">-</span><span class="pl-c1">11</span><span class="pl-c1">-</span><span class="pl-c1">01</span> <span class="pl-c1">07</span>:<span class="pl-c1">45</span>:<span class="pl-c1">00</span>          <span class="pl-c1">18</span>           <span class="pl-c1">8</span>
  <span class="pl-c1">2016</span><span class="pl-c1">-</span><span class="pl-c1">11</span><span class="pl-c1">-</span><span class="pl-c1">01</span> <span class="pl-c1">09</span>:<span class="pl-c1">00</span>:<span class="pl-c1">00</span>          <span class="pl-c1">19</span>           <span class="pl-c1">9</span>

<span class="pl-v">In</span> [<span class="pl-c1">83</span>]: <span class="pl-s1">c_fi</span> <span class="pl-c1">=</span> <span class="pl-s1">pandas</span>.<span class="pl-en">date_range</span>(<span class="pl-s1">c</span>.<span class="pl-s1">index</span>.<span class="pl-en">get_level_values</span>(<span class="pl-c1">1</span>).<span class="pl-en">min</span>(), <span class="pl-s1">c</span>.<span class="pl-s1">index</span>.<span class="pl-en">get_level_values</span>(<span class="pl-c1">1</span>).<span class="pl-en">max</span>(), <span class="pl-s1">freq</span><span class="pl-c1">=</span><span class="pl-s">'15Min'</span>, <span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">'a'</span>)

<span class="pl-v">In</span> [<span class="pl-c1">85</span>]: <span class="pl-en">len</span>(<span class="pl-s1">c_fi</span>)
<span class="pl-v">Out</span>[<span class="pl-c1">85</span>]: <span class="pl-c1">13</span>

<span class="pl-v">In</span> [<span class="pl-c1">87</span>]: <span class="pl-s1">c</span>.<span class="pl-en">reindex</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">c_fi</span>, <span class="pl-s1">level</span><span class="pl-c1">=</span><span class="pl-c1">1</span>).<span class="pl-s1">shape</span>
<span class="pl-v">Out</span>[<span class="pl-c1">87</span>]: (<span class="pl-c1">6</span>, <span class="pl-c1">2</span>)</pre></div>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">As in the single-level index case:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In [88]: c.reset_index(level=0).reindex(index=c_fi).shape
Out[88]: (13, 3)"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">88</span>]: <span class="pl-s1">c</span>.<span class="pl-en">reset_index</span>(<span class="pl-s1">level</span><span class="pl-c1">=</span><span class="pl-c1">0</span>).<span class="pl-en">reindex</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">c_fi</span>).<span class="pl-s1">shape</span>
<span class="pl-v">Out</span>[<span class="pl-c1">88</span>]: (<span class="pl-c1">13</span>, <span class="pl-c1">3</span>)</pre></div>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.13.final.0
python-bits: 64
OS: Darwin
OS-release: 16.4.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
<p dir="auto">pandas: 0.19.2<br>
nose: 1.3.7<br>
pip: 9.0.1<br>
setuptools: 28.6.1<br>
Cython: 0.25.2<br>
numpy: 1.11.3<br>
scipy: 0.18.1<br>
statsmodels: 0.6.1<br>
xarray: 0.9.1<br>
IPython: 5.1.0<br>
sphinx: 1.5.1<br>
patsy: 0.4.1<br>
dateutil: 2.6.0<br>
pytz: 2016.10<br>
blosc: None<br>
bottleneck: 1.2.0<br>
tables: 3.3.0<br>
numexpr: 2.6.1<br>
matplotlib: 2.0.0<br>
openpyxl: 2.4.1<br>
xlrd: 1.0.0<br>
xlwt: 1.2.0<br>
xlsxwriter: 0.9.6<br>
lxml: 3.7.2<br>
bs4: 4.5.3<br>
html5lib: None<br>
httplib2: None<br>
apiclient: None<br>
sqlalchemy: 1.1.5<br>
pymysql: None<br>
psycopg2: 2.6.2 (dt dec pq3 ext lo64)<br>
jinja2: 2.9.4<br>
boto: 2.45.0<br>
pandas_datareader: None</p>
</details>
<p dir="auto">xref <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="88005806" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/10347" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/10347/hovercard" href="https://github.com/pandas-dev/pandas/issues/10347">#10347</a></p>
<p dir="auto">I'm having trouble understand how exactly reindex is supposed to work in the case of MultiIndex.  What I would like is the exact behavior in the Index case where values can be filled or padded according to some level of the MultiIndex.  I can't understand what reindex is doing in the MultiIndex case.  The below is an example where I would like to interpolate using the prior value a month frame to an hourly frame.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import pandas as pd
d1 = pd.date_range('1/1/2012', '3/1/2012', freq='MS')
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}, index=d1)
dfu = df.unstack()

dfu
Out[12]: 
A  2012-01-01    1
   2012-02-01    2
   2012-03-01    3
B  2012-01-01    4
   2012-02-01    5
   2012-03-01    6
dtype: int64

d2 = pd.date_range('1/1/2012', '3/31/2012', freq='D')

dfu.reindex(d2, level=1) # What is this supposed to do?
Out[17]: 
A  2012-01-01    1
   2012-02-01    2
   2012-03-01    3
B  2012-01-01    4
   2012-02-01    5
   2012-03-01    6
dtype: int64

df.reindex(d2, method='pad').unstack() #Ideally something like this, but without the trickery
Out[19]: 
A  2012-01-01    1
   2012-01-02    1
   2012-01-03    1
   2012-01-04    1
   2012-01-05    1
   2012-01-06    1
   2012-01-07    1
   2012-01-08    1
   2012-01-09    1
   2012-01-10    1
   2012-01-11    1
   2012-01-12    1
   2012-01-13    1
   2012-01-14    1
   2012-01-15    1
...
B  2012-03-17    6
   2012-03-18    6
   2012-03-19    6
   2012-03-20    6
   2012-03-21    6
   2012-03-22    6
   2012-03-23    6
   2012-03-24    6
   2012-03-25    6
   2012-03-26    6
   2012-03-27    6
   2012-03-28    6
   2012-03-29    6
   2012-03-30    6
   2012-03-31    6
Length: 182, dtype: int64"><pre class="notranslate"><code class="notranslate">import pandas as pd
d1 = pd.date_range('1/1/2012', '3/1/2012', freq='MS')
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}, index=d1)
dfu = df.unstack()

dfu
Out[12]: 
A  2012-01-01    1
   2012-02-01    2
   2012-03-01    3
B  2012-01-01    4
   2012-02-01    5
   2012-03-01    6
dtype: int64

d2 = pd.date_range('1/1/2012', '3/31/2012', freq='D')

dfu.reindex(d2, level=1) # What is this supposed to do?
Out[17]: 
A  2012-01-01    1
   2012-02-01    2
   2012-03-01    3
B  2012-01-01    4
   2012-02-01    5
   2012-03-01    6
dtype: int64

df.reindex(d2, method='pad').unstack() #Ideally something like this, but without the trickery
Out[19]: 
A  2012-01-01    1
   2012-01-02    1
   2012-01-03    1
   2012-01-04    1
   2012-01-05    1
   2012-01-06    1
   2012-01-07    1
   2012-01-08    1
   2012-01-09    1
   2012-01-10    1
   2012-01-11    1
   2012-01-12    1
   2012-01-13    1
   2012-01-14    1
   2012-01-15    1
...
B  2012-03-17    6
   2012-03-18    6
   2012-03-19    6
   2012-03-20    6
   2012-03-21    6
   2012-03-22    6
   2012-03-23    6
   2012-03-24    6
   2012-03-25    6
   2012-03-26    6
   2012-03-27    6
   2012-03-28    6
   2012-03-29    6
   2012-03-30    6
   2012-03-31    6
Length: 182, dtype: int64
</code></pre></div>