Exclude items from one list based on second list in Python

I've searched for over an hour and haven't found exactly such a solution, but most likely asked for it - any pointers are very welcome.

I have time series data (time, flow) at intervals from Kepler satellite. I filled in the missing points to apply a high pass Fourier filter. Now I want to remove the filled points from the filtered data (time, flux_residuals), so I only have the time values ​​that were in the original data.

So, as a side-by-side example, let's say my raw data and filtered data are:

xorig = np.array([1,2,5,6]) 
yorig = (doesn't matter)

xf = np.array([1,2,3,4,5,6]) 
yf = xf + 10

      

What is the pythonic way to extract elements from yf where the corresponding xf elements are in xorig?

[11,12,15,16]

      

+3


source to share


1 answer


Perhaps np.in1d :



print(yf[np.in1d(xf, xorig)])

[11 12 15 16]

      

+1


source







All Articles