I have a DataFrame which has many stocks (in this case just GM and F), Sales growth, stock growth.
import pandas as pd
import numpy as np
d = {'year': [2000, 2000, 2001, 2001, 2002, 2002, 2003, 2003, 2004, 2004], 'Stock': ["GM", "F", "GM", "F", "GM", "F", "GM", "F", "GM", "F"], 'US Sales Growth': [.3, .3, .1, .1, .6, .6, .12, .12, .7, .7], 'Stock Growth': [.1, .2, .3, .4, .14, .16, .2, .1,.15,.16]}
df = pd.DataFrame(data=d)
My goal is to add a column that is called "closets_sales_growth_corresponding_stock_growth" that matches the current sales growth to past sales growths and collects the stock growth corresponding to the closest past sales growth to a new column.
It should look like this:

