Similar to the solution here, you can find the first non nan value, then slice your array from this index onwards. Easy to use the numpy.where
method, similar to how they use it in this answer
This should work:
arr[np.where( np.isnan(arr)==False)[0][0]:]
of course if you want to actually override the old array you can do:
arr = arr[np.where( np.isnan(arr)==False)[0][0]:]
and in the example:
import numpy as np
arr = np.array((np.nan, np.nan, 2.3, np.nan, np.nan, 6.4, np.nan))
result = arr[np.where( np.isnan(arr)==False)[0][0]:]
has [2.3 nan nan 6.4 nan]
in result
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…