Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python selecting values that are close to each other with values in both arrays

I have two arrays.

org_df = [2732.64, 2296.35, 1262.28, 567.6, 436.29, 262.98, 238.74, 210.38,19]
calc_df = [19, 2296.34, 436.3, 2732.64]

I want to compare these arrays and create a new array with the same elements and with 0.01 tolerance.

new_list = [2732.64, 2296.35 ,436.29,19]

I added the code but it doesn’t work:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

picture showing code

>Solution :

new_list = [i for i in org_df if np.any(np.isclose(i, calc_df, atol=0.01))]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading