<p dir="auto">The following example works:</p>
<p dir="auto">df = DataFrame(np.arange(20).reshape(5,4))<br>
df2 = df.set_index(keys=[0,1,2])<br>
df2.ix[(4,5,6)]</p>
<p dir="auto">for using a MultiIndex</p>
<p dir="auto">So I created a file sample_data.csv that looks like this:</p>
<p dir="auto">col1,col2,year,amount<br>
111111,3.5,2012,700<br>
111112,3.5,2011,600<br>
222221,4.0,2012,222<br>
...</p>
<p dir="auto">I then ran the following:</p>
<p dir="auto">import numpy as np<br>
import pandas as pd<br>
sd=pd.read_csv('sample_data.csv')<br>
sd2=sd.set_index(keys=['col2','year'])<br>
sd2.ix[(4.0,2012)]</p>
<p dir="auto">But this produces the following error: IndexError: index out of bounds<br>
Can anyone explain why the former example works, but the latter doesn't ?</p>
<p dir="auto">I was wondering if, given the recent set of developments and improvements to <code class="notranslate">asfreq</code> and <code class="notranslate">resample</code>, we now have a more efficient method for solving <a href="http://stackoverflow.com/questions/29356412/efficiently-re-indexing-one-level-with-forward-fill-in-a-multi-index-dataframe" rel="nofollow">this problem</a> [from SO].</p>
<p dir="auto">Example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="item_uid   created_at     value     
0S0099v8iI 2015-03-25  10652.79
0F01ddgkRa 2015-03-25   1414.71
0F02BZeTr6 2015-03-20  51505.22
0F02BZeTr6 2015-03-23  51837.97
0F02BZeTr6 2015-03-24  51578.63
0F02BZeTr6 2015-03-25       NaN
0F02BZeTr6 2015-03-26       NaN
0F02BZeTr6 2015-03-27  50893.42
0F02BcIzNo 2015-03-17   1230.00
0F02BcIzNo 2015-03-23   1130.00
0F02F4gAMs 2015-03-25   1855.96
0F02Vwd6Ou 2015-03-19   5709.33
0F04OlAs0R 2015-03-18    321.44
0F05GInfPa 2015-03-16    664.68
0F05PQARFJ 2015-03-18   1074.31
0F05PQARFJ 2015-03-26   1098.31
0F06LFhBCK 2015-03-18    211.49
0F06ryso80 2015-03-16     13.73
0F06ryso80 2015-03-20     12.00
0F07gg7Oth 2015-03-19   2325.70"><pre class="notranslate"><code class="notranslate">item_uid   created_at     value     
0S0099v8iI 2015-03-25  10652.79
0F01ddgkRa 2015-03-25   1414.71
0F02BZeTr6 2015-03-20  51505.22
0F02BZeTr6 2015-03-23  51837.97
0F02BZeTr6 2015-03-24  51578.63
0F02BZeTr6 2015-03-25       NaN
0F02BZeTr6 2015-03-26       NaN
0F02BZeTr6 2015-03-27  50893.42
0F02BcIzNo 2015-03-17   1230.00
0F02BcIzNo 2015-03-23   1130.00
0F02F4gAMs 2015-03-25   1855.96
0F02Vwd6Ou 2015-03-19   5709.33
0F04OlAs0R 2015-03-18    321.44
0F05GInfPa 2015-03-16    664.68
0F05PQARFJ 2015-03-18   1074.31
0F05PQARFJ 2015-03-26   1098.31
0F06LFhBCK 2015-03-18    211.49
0F06ryso80 2015-03-16     13.73
0F06ryso80 2015-03-20     12.00
0F07gg7Oth 2015-03-19   2325.70
</code></pre></div>
<p dir="auto">which, if we were to resample with a daily frequency, would return (e.g. for <code class="notranslate">item_uid = 0F02BZeTr6</code>):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="item_uid   created_at     value     
0F02BZeTr6 2015-03-20  51505.22
0F02BZeTr6 2015-03-21  51505.22
0F02BZeTr6 2015-03-22  51505.22
0F02BZeTr6 2015-03-23  51837.97
0F02BZeTr6 2015-03-24  51578.63
0F02BZeTr6 2015-03-25  51578.63
0F02BZeTr6 2015-03-26  51578.63
0F02BZeTr6 2015-03-27  50893.42
0F02BZeTr6 2015-03-28  50893.42
0F02BZeTr6 2015-03-29  50893.42"><pre class="notranslate"><code class="notranslate">item_uid   created_at     value     
0F02BZeTr6 2015-03-20  51505.22
0F02BZeTr6 2015-03-21  51505.22
0F02BZeTr6 2015-03-22  51505.22
0F02BZeTr6 2015-03-23  51837.97
0F02BZeTr6 2015-03-24  51578.63
0F02BZeTr6 2015-03-25  51578.63
0F02BZeTr6 2015-03-26  51578.63
0F02BZeTr6 2015-03-27  50893.42
0F02BZeTr6 2015-03-28  50893.42
0F02BZeTr6 2015-03-29  50893.42
</code></pre></div>
<p dir="auto">I mention this partly because <code class="notranslate">unstacking</code> can be very slow when our index is huge. Any thoughts here are welcome!</p>