Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove elements from numpy array smaller than 1

I am trying to plot large data (50 million values) but I am getting a MemoryError. Now I am trying to clear my dataset from redundant values. In my case, these are all values below 1 and above -1. One thing to keep in mind is that the plot should look the same as the original, but without the noise. Is there a better way to do this than using loops or list comprehensions?

Original Plot:

enter image description here

Edit:

Thank you for the replies. If I use the proposed approach:

daty = daty[(-1 > daty) | (daty > 1)]

It results in this:

enter image description here

like image 621
Artur Müller Romanov Avatar asked May 11 '26 02:05

Artur Müller Romanov


1 Answers

If your array is named data:

clipped_data = data[(-1 > data) | (data > 1)]
like image 171
gmds Avatar answered May 13 '26 15:05

gmds



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!