Trying to find an approximate match in a Column
 Trying to find an approximate match in a Column ankur2207 Programmer named Tim Posts: 5 Threads: 3 Joined: Sep 2017 Reputation: Sep-02-2017, 09:46 AM my question here Hi everyone, I've just started learning Python so no idea about 'how to find an approximate match of a value in Integer type of column' `my code here` Reply Larz60+ aetate et sapientia Posts: 10,770 Threads: 407 Joined: Sep 2016 Reputation: Sep-02-2017, 10:32 AM Please read this you need to give a lot more information on what you are trying to do! Reply ankur2207 Programmer named Tim Posts: 5 Threads: 3 Joined: Sep 2017 Reputation: Sep-02-2017, 01:02 PM Hi Sir, So I have a column of integer values and generating random number. Now I need to find an exact or approximate match of that Random Number. For Example: Generated Random Number=55355 Exact match=55355 but when exact match is not in the data then we'll find approximate match and it can be 55280. Kindly help me solving this and many thanks in advance. Regards, Ankur K Reply sparkz_alot Da Bishop Posts: 1,298 Threads: 38 Joined: Sep 2016 Reputation: Sep-02-2017, 01:46 PM (This post was last modified: Sep-02-2017, 01:46 PM by sparkz_alot.) If you are using v 3.5 +, you can try outÂ math.isclose() If it ain't broke, I just haven't gotten to it yet. OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch" Python 3.6.5, IDE: PyCharm 2018 Community Edition Reply hbknjr Lumberjack Posts: 101 Threads: 7 Joined: Aug 2017 Reputation: Sep-02-2017, 02:04 PM math.isclose() can be helpful. It also lets you define the degree of approximation(relative and absolute tolerance). (Sep-02-2017, 01:02 PM)ankur2207 Wrote: So I have a column of integer values and generating random number. Now I need to find an exact or approximate match of that Random Number. But if you want to find the closest match in a list of the number then you can use: `closest = min(random_list, key=lambda x:abs(x-random_num))` Reply

 Possibly Related Threads… Thread Author Replies Views Last Post pandas pivot table: How to find count for each group in Index and Column JaneTan 0 275 Oct-23-2021, 04:35 AM Last Post: JaneTan Find factor to match test curve to golden curve SriRajesh 0 464 Jun-17-2021, 04:39 AM Last Post: SriRajesh OpenPyxl: How to iterate through each Column (in 1 row) to find a value? chatguy 2 8,546 Apr-06-2021, 04:52 AM Last Post: carlhyde find empty cells in a column Pedroski55 2 20,808 Sep-18-2017, 01:27 PM Last Post: Pedroski55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020