Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading