A frame containing NaN values is reshaped with stack() and then unstack(). What is the result compared with the original?
Correct answer
D. The original shape, with the same missing values still in place there
13 views
D. The original shape, with the same missing values still in place there
13 views
stack pivots the innermost column level into the row index and unstack performs the inverse, so a round trip restores the original shape and values. Missing combinations behave differently in each direction: stack has a dropna option while unstack refills absent intersections with NaN. Column order can differ after the round trip even when the values match.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is D? Ask here and get an explanation.