Question: I added a redirection link to the reference numbers in a grid that link back to receipts. I followed the instructions given in T200 to perform the task, except 
I made the page that opens a popup instead of a new tab. It works for the first reference number I click, but after that it doesn't change the record. Instead the popup displays the record for the first reference number I clicked. Here is my code:

```
    protected void RefNbrReceipt()
    {
        INRegister row = Receipts.Current;

        INReceiptEntry graph = PXGraph.CreateInstance<INReceiptEntry>();

        graph.receipt.Current = graph.receipt.Search<INRegister.refNbr>(row.RefNbr);

        if (graph.receipt.Current != null)
        {
            throw new PXPopupRedirectException(graph, "Receipt Details");
        }
    }

```

I checked and made sure that the row updates to the selected value (I do have SyncPosition = true on the grid) as well as after the Search that graph.receipt.Current.RefNbr = row.RefNbr. All of the objects in the code when debugging and stepping through it are set to the correct values they should be. Even though these values are showing correctly, when the popup appears, it still has the incorrect record (the first record fetched).

Answer: 
Pass the index label to `loc` and the col of interest:

```
In[198]:
df.loc[diff_row.idxmax(), 'City']

Out[198]: 'Dallas'

```
Taking a step back and using `numpy.ptp` (peak to peak) to do the subtraction of max less min.

```
df.set_index('City').apply(np.ptp, 1).idxmax()

'Dallas'

```

---

We can push more over to `numpy` with

```
df.City.values[np.ptp(df.set_index('City').values, 1).argmax()]

'Dallas'

```

---

**Timing** 

```
%timeit df.City.values[np.ptp(df.set_index('City').values, 1).argmax()]
%timeit df.set_index('City').apply(np.ptp, 1).idxmax()
1000 loops, best of 3: 399 µs per loop
1000 loops, best of 3: 1.03 ms per loop

%%timeit 
diff_row = df.max(axis=1) - df.min(axis=1)
df.loc[diff_row.idxmax(), 'City']
1000 loops, best of 3: 1.24 ms per loop

```