2

I have two dataframes:

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           

and

historicPower

   power
0    0.0
1    0.0
2    0.0
3   -1.0
4    0.0
5    1.0
7    0.0

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

   power

1    0.0
2    0.0
3   -1.0
4    0.0
5    1.0
7    0.0

The dataframes in reality will be alot larger with different shapes.

halfer
  • 19,824
  • 17
  • 99
  • 186
Stacey
  • 4,825
  • 17
  • 58
  • 99
  • 2
    Is index contain duplicates? If not, use `historicPower = historicPower.reindex(dayData.index)` – jezrael Aug 31 '16 at 11:26

1 Answers1

5

I think you can use reindex if index has no duplicates:

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
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252