Minimum Attribute and replacing 0 with no data value

Discussion created by HCarlos on Apr 8, 2013
I've performed some massive OD cost matrices, and then using the pivot table function, I have the results in a table where each row is an origin and each column is a destination and all the values are the travel times between the origins and destinations.

Now I need to do several things:
a) calculate the TIME to the closest facility (ignoring the 0's which are really no data)
b) calculate the NAME of the facility which is the closest
c) replace all the 0 values (an artifact of the pivot table function, which uses a 0 to indicate when no origin-destination solution was found) with our no data value (-1).

My python skills are novice level.  I managed to accomplish Task (a) with the following:
def mingt(a, b, c, d, e, f):
  L = [a,b,c,d,e,f]
  if L != [0,0,0,0,0,0]:
    M = min(x for x in L if x!=0)
    return M
    return -1

For task (b), I want the name of the attribute for which I returned the value in task (a).  I'm a bit lost in how to access the name of the attribute.  So, any suggestions would be great.

For task (c), I'm guessing this is a massive loop, but I'm hoping some folks have some smart ideas on how to do this as I have a table that is 900,000 rows by 240 columns as well as a bunch of smaller, but still large tables.

Thanks for any help,