Reshape dataframe to have the same index as another dataframe
<p>I have two dataframes:</p>

<pre><code>dayData


        power_comparison      final_average_delta_power calculated_power
1                    0.0               0.0                  0       
2                    0.0               0.0                  0           
3                    0.0               0.0                  0           
4                    0.0               0.0                  0       
5                    0.0               0.0                  0           
7                    0.0               0.0                  0           
</code></pre>

<p>and </p>

<pre><code>historicPower

   power
0    0.0
1    0.0
2    0.0
3   -1.0
4    0.0
5    1.0
7    0.0
</code></pre>

<p>I'm trying to reindex the <code>historicPower</code> dataframe to have the same shape as the <code>dayData</code> dataframe (so in this example it would looks like):</p>

<pre><code>   power

1    0.0
2    0.0
3   -1.0
4    0.0
5    1.0
7    0.0
</code></pre>

<p>The dataframes in reality will be alot larger with different shapes.  </p>

<p>Any help much appreciated.</p>

<p>I think you can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.reindex.html" rel="nofollow"><code>reindex</code></a> if <code>index</code> has no duplicates:</p>

<pre><code>historicPower = historicPower.reindex(dayData.index) 
print (historicPower)
   power
1    0.0
2    0.0
3   -1.0
4    0.0
5    1.0
7    0.0
</code></pre>

python pandas indexing dataframe reindex