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,
Well here is a way to do it. Probably not the most efficient though:
list(map(lambda x: [i for i, x_ in enumerate(x) if not np.isnan(x_)][-1], a))
Also it will fail if any row is fully 'nan' because python will try to do getitem on an empty list.
getitem