Premium problem140. Stack Frames With Different Columns

Medium Locked

first and second share some columns but not all.

Stack them row-wise keeping the union of the columns, filling the cells a frame had no column for with NaN. Order the columns as they first appear, reading first left to right and then any columns only second has. Renumber the index from 0.

Input

first =
   id name
0   1    a
1   2    b
second =
   id  score
0   3    9.5

Output

   id name  score
0   1    a    NaN
1   2    b    NaN
2   3  NaN    9.5

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)