It uses a vector approach with NumPy tools -
a = df.x.values
m = np.concatenate(( [True], np.isnan(a), [True] ))
ss = np.flatnonzero(m[1:] != m[:-1]).reshape(-1,2)
start,stop = ss[(ss[:,1] - ss[:,0]).argmax()]
Run Example -
In [474]: a
Out[474]:
array([ 1., nan, 3., nan, nan, nan, nan, 8., 7., 5., 2.,
5., nan, nan])
In [475]: start, stop
Out[475]: (7, 12)
The intervals are set so that the difference between each start and stop gives us the length of each interval. So, ending indexif you want to get the last index of a nonzero element, we need to subtract it from stop.