Max value geoprocessing , python problem

89
2
03-12-2019 08:53 AM
timfajr
New Contributor

Hi.. I'm having some trouble, i want to insert a survey into table on arcgis pro, example: i have two collums a and b, in collum a the value is 5, in collum b the value is 10, i want to display the biggest value so i enter the code: "maxvalue(a, b) and so the result is 10, the problem is i want to display the field name, not the result, so in this case, 5 vs 10=" b", can anyone tell me how to write the code?

0 Kudos
2 Replies
RandyBurton
MVP Regular Contributor

Are you thinking of .index in something like:

fields = ['a', 'b']
rows = [[ 5, 10],[20,10]]
for row in rows:
print max(row), fields[row.index(max(row))]

# results:
# 10 b
# 20 a
JoshuaBixby
MVP Esteemed Contributor

Using field calculator dialog in Pro, set the Expression Type to Python 3, and paste the following into the expression box (not Code Block):

max((!col_a!,'col_a'),(!col_b!,'col_b'))[1]