Premium problem57. Reindex Rows and Columns

Medium Locked

Produce a new DataFrame with rows ['y', 'z', 'w'] and columns ['a', 'c'], pulling matching values from df; any row or column label not present in the original becomes NaN.

Input

   a  b  c
x  1  4  7
y  2  5  8
z  3  6  9

Output

     a    c
y  2.0  8.0
z  3.0  9.0
w  NaN  NaN

Premium problem

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

Implement solve(...)