I've the following pandas dataframe:
>>> df = pd.DataFrame([
[np.nan, 2, 'x', 0],
[3, 4, 'y', 0],
[9, 6, 'x', 1],
[np.nan, np.nan, 'y', 1]],
columns=['ignore', 'value', 'col', 'row'])
>>> df
ignore value col row
0 NaN 2.0 x 0
1 3.0 4.0 y 0
2 9.0 6.0 x 1
3 NaN NaN y 1
I want to be able to convert it to something like the following:
x y
0 2.0 4.0
1 6.0 NaN
Is it possible using pivot or multi-index or anything else? Or the only possible solution is looping through individual values?