I would like to add a new column 'Vth' in my table with the following calculation:-
First I need to find the index i of column 'Id' where the 'Id' is nearest to 1e-6; and then Vth = Vg(i). It should be grouped by Mod and Device columns as well. That is, each unique combination of Mod and Device will have one Vth value.
| Id | Vg | Mod | Device | Vth |
| 2.00E-06 | 3 | 1A | X1 | |
| 2.00E-07 | 2.8 | 1A | X1 | |
| 2.00E-08 | 2.6 | 1A | X1 | |
| 2.00E-09 | 2.4 | 1A | X1 | |
| 2.00E-10 | 2.2 | 1A | X1 | |
| 2.00E-12 | 2 | 1A | X1 | |
| 3.00E-06 | 3 | 1B | X1 | |
| 3.00E-07 | 2.8 | 1B | X1 | |
| 3.00E-08 | 2.6 | 1B | X1 | |
| 3.00E-09 | 2.4 | 1B | X1 | |
| 3.00E-10 | 2.2 | 1B | X1 | |
| 3.00E-12 | 2 | 1B | X1 | |
| 4.00E-06 | 3 | 1A | Y1 | |
| 4.00E-07 | 2.8 | 1A | Y1 | |
| 4.00E-08 | 2.6 | 1A | Y1 | |
| 4.00E-09 | 2.4 | 1A | Y1 | |
| 4.00E-10 | 2.2 | 1A | Y1 | |
| 4.00E-12 | 2 | 1A | Y1 | |
| 5.00E-06 | 3 | 1B | Y1 | |
| 5.00E-07 | 2.8 | 1B | Y1 | |
| 5.00E-08 | 2.6 | 1B | Y1 | |
| 5.00E-09 | 2.4 | 1B | Y1 | |
| 5.00E-10 | 2.2 | 1B | Y1 | |
| 5.00E-12 | 2 | 1B | Y1 | |