2

If i have two data frames df1 and df2:

df1

 yr 24 1984 30 1985 

df2

 d m yr 16 12 4 2012 17 13 10 1976 18 24 4 98 

I would like to have a dataframe that gives an output as below, could you help with the function that could help me achieve this

 d m yr 16 12 4 2012 17 13 10 1976 18 24 4 98 24 NaN NaN 1984 30 NaN NaN 1985 

1 Answer 1

2

You are looking to concat two dataframes:

res = pd.concat([df2, df1], sort=False) print(res) d m yr 16 12.0 4.0 2012 17 13.0 10.0 1976 18 24.0 4.0 98 24 NaN NaN 1984 30 NaN NaN 1985 
Sign up to request clarification or add additional context in comments.

3 Comments

What if there are is index number 19,20,25,31 also in df1. How do I go about it then?
Not sure what the problem is in that situation. This method will still work, have you tried it?
Oh... there were some more operations that were needed to be performed... once I did that .. it worked.... thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.