I have the following table:
year pop1 pop2
0 0 100000 100000
1 1 999000 850000
2 2 860000 700000
3 3 770000 650000
I want to find for each pop (pop1 ,pop2) the year the pop was closest to a given number, for example, the year the pop was the closest to 830000.
Is there any way to find the nearest value inside column based on given value?
I have seen this post (How do I find the closest values in a Pandas series to an input number?_ but seems like here the result is above and below and I wat to get in the end only one number.
*I don't have code example because I don't find any argument to use to get the nearest