def interpTRK(targetAge, df): ages = df.AGE closestGreater = ages[ages > targetAge].min() closestLess = ages[ages < targetAge].max() row_closest_less = df[df['AGE'] == closestLess] row_closest_greater = df[df['AGE'] == closestGreater] fraction = (targetAge - closestLess) / (closestGreater - closestLess) interpolated_row = row_closest_less.drop(columns=['AGE']).reset_index(drop=True) + \ fraction * (row_closest_greater.drop(columns=['AGE']).reset_index(drop=True) - row_closest_less.drop(columns=['AGE']).reset_index(drop=True)) return interpolated_row