Python Forum
Trying to find an approximate match in a Column
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to find an approximate match in a Column
#5
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


Messages In This Thread
RE: Trying to find an approximate match in a Column - by hbknjr - Sep-02-2017, 02:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Find a string from a column of one table in another table visedwings049 8 1,246 Sep-07-2023, 03:22 PM
Last Post: deanhystad
  Find last filled column in openpyxl Irv1n 2 12,953 Jan-16-2022, 11:05 AM
Last Post: Pedroski55
  pandas pivot table: How to find count for each group in Index and Column JaneTan 0 3,365 Oct-23-2021, 04:35 AM
Last Post: JaneTan
  Find factor to match test curve to golden curve SriRajesh 0 1,581 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 18,192 Apr-06-2021, 04:52 AM
Last Post: carlhyde
  find empty cells in a column Pedroski55 2 23,865 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