Suppose I have data of the form
Name h1 h2 h3 h4
A 1 nan 2 3
B nan nan 1 3
C 1 3 2 nan
I want to move all non-nan cells to the left (or collect all non-nan data in new columns) while preserving the order from left to right, getting
Name h1 h2 h3 h4
A 1 2 3 nan
B 1 3 nan nan
C 1 3 2 nan
I can of course do so row by row. But I hope to know if there are other ways with better performance.
See Question&Answers more detail:os