BUG: unstack(fill_value) does nothing when unstacking multiple columns · Issue #13971 · pandas-dev/pandas (original) (raw)
In #9746 we got a fill_value
argument for pd.unstack()
. But it does nothing if we unstack multiple levels at once:
df = pd.DataFrame({'x':['a', 'a', 'b'], 'y':['j', 'k', 'j'], 'z':[0, 1, 2], 'w':[0, 1, 2]})
df.set_index(['x', 'y', 'z']).unstack(['x', 'y'], fill_value=0)
w
x a b
y j k j
z
0 0.0 NaN NaN
1 NaN 1.0 NaN
2 NaN NaN 2.0
It should give zeros instead of NaN.
Pandas 0.18.1.