我有两个数据帧:
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
和
historicPower
power
0 0.0
1 0.0
2 0.0
3 -1.0
4 0.0
5 1.0
7 0.0
我尝试重新索引historicPower
数据框,使其具有与dayData
数据框相同的形状(因此在此示例中看起来如此):
power
1 0.0
2 0.0
3 -1.0
4 0.0
5 1.0
7 0.0
现实中的数据帧会因形状不同而变得更大。
答案 0 :(得分:3)
如果index
没有重复项,我认为你可以使用reindex
:
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