简体   繁体   中英

Exclude items from one list based on second list in Python

I've searched for more than an hour and haven't found exactly the solution to this, but it likely has been asked - any pointers are very welcome.

I have time series data (time, flux) with gaps from the Kepler satellite. I filled in missing points so I could apply a Fourier high-pass filter. Now I want to delete the filled points from the filtered data (time, flux_residuals) so I have only the time values that were in the original data.

So as a parallel example, say that my original 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 a pythonic way to extract the elements in yf where corresponding elements of xf are in xorig?

[11,12,15,16]

Maybe np.in1d :

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

[11 12 15 16]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM