Problems extending pandas Panels dynamically, DataFrame by DataFrame
<p>I want to construct a pandas panel dynamically, using the following - simplified - code:</p>

<pre><code>import pandas as pd 
rows=range(0,3)
pl=pd.Panel()
for i in range(0,3):
    pl[i]=pd.DataFrame()
    for j in rows:
        pl[i].set_value(j,'test_value','test')
</code></pre>

<p>Which seems to work fine. But when I the try to index the individual dataframes by </p>

<pre><code>for i in range(0,3):
    print pl[i]
</code></pre>

<p>I get the output </p>

<pre><code>Empty DataFrame
Columns: []
Index: []
Empty DataFrame
Columns: []
Index: []
  test_value
0     test20
1     test21
2     test22
</code></pre>

<p>Why are the first two frames empty? </p>

<p>Use two for loops to solve this problem:</p>

<pre><code>import pandas as pd 

rows=range(0,3)
pl=pd.Panel()

#first for loop to create dataframe
for i in range(0,3):
    pl[i]=pd.DataFrame()

#Second for loop to assign values
for i in range(0,3):    
    for j in rows:
        pl[i].set_value(j,'test_value','test')
</code></pre>

<p>This time you won't get empty dataframes :)</p>

python pandas