Quickest way to iterate over a pandas dataframe and perform an operation on a column, when what the operation is depends on the row I have a table that is laid out somewhat like this: