简体   繁体   English

Append 单列 dataframe 到最后一个 DataFrame

[英]Append a single Column dataframe to another DataFrame in the last

I have two dataframes:我有两个数据框:

Actual_Values
0   0.60
1   0.60
2   0.60
3   0.60
4   0.60


Predicted_Values
0   0.60
1   0.60
2   0.60

and I want a something like this:我想要这样的东西:

Actual_Values   Predicted_Values
0   0.60    NaN
1   0.60    NaN
2   0.60    0.6
3   0.60    0.6
4   0.60    0.6

I have tried pandas' join, merge, concat, but none works.我已经尝试过 pandas 的 join、merge、concat,但都没有。

Try with assign the new index尝试分配新索引

df2.index=df1.index[-len(df2):]
out = df1.join(df2)
Out[283]: 
   Actual_Values  Predicted_Values
0            0.6               NaN
1            0.6               NaN
2            0.6               0.6
3            0.6               0.6
4            0.6               0.6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM