Given a numpy array (or pandas dataframe) like this:
import numpy as np a = np.array([ [1, 1, 1, 0.5, np.nan, np.nan, np.nan], [1, 1,
This solution doesn't require the array to be sorted. It just returns the last non nan item along axis 1.
(~np.isnan(a)).cumsum(1).argmax(1)