def pir(x):
    x = np.append(np.nan, np.append(x, np.nan))
w = np.where(np.isnan(x))[0]
a = np.diff(w).argmax()
return w[[a, a + 1]] + np.array([0, -2])
Pandas - Find longest stretch without Nan values