I have a DataFrame containing forecasts called fcst that looks like this:
yhat yhat_lower yhat_upper
ds
2015-08-31 -0.443522 -19.067399 17.801234
2015-09-30 6.794625 -31.472186 46.667981
...
After making this transformation:
fcst2 = fcst["yhat"].to_frame().rename(columns={"yhat":"test1"})
fcst3 = fcst["yhat"].to_frame().rename(columns={"yhat":"test2"})
I want to concatenate them, on the date index as such:
pd.concat([fcst2,fcst3])
But I receive a DataFrame that is not aligned on the index:
test1 test2
ds
2015-08-31 -0.443522 NaN
2015-09-30 6.794625 NaN
... ... ...
2017-05-31 NaN 95.563262
2017-06-30 NaN 85.829916
and this despite:
(fcst2.index == fcst3.index).any()
returning True.
My question is: why aren't the two DataFrames being concatenated on the index and what can I do to solve this?
I know of the join function, but as some dates will be missing in some of the other DataFrames which I'm planning on adding I believe that the concat function might be better.