Hi Peter,Looking at the desired result, you could use something like this:import arcpy
# your data:
tbl = r'C:\Project\_Forums\_maxDict\fgdb\test.gdb\aTable'
fld_quin = 'Quinary'
fld_wma = 'WMA' # Water Management Area
fld_perc = 'Percentage'
fld_oid = arcpy.Describe(tbl).OIDfieldname # or specify ID fieldname
# create empty dictionary to store results
dct = {}
# loop through table
flds = (fld_oid, fld_quin, fld_wma, fld_perc)
with arcpy.da.SearchCursor(tbl, flds) as curs:
for row in curs:
oid, perc = row[0], row[3]
quin, wma = row[1], row[2]
if quin in dct:
max_perc = dct[quin][2]
if perc > max_perc:
dct[quin] = (oid, wma, perc)
else:
dct[quin] = (oid, wma, perc)
# print results
for quin, val in dct.items():
print val[0], quin, val[1], val[2]
This produces the following output:3 Q1 W2 50.0
4 Q2 W3 90.0The dictionary holds the Quinary as key value and a tuple of OID, WMA and Percentage as value. In this case the maximum percentage is stored per Quinary. In case you are interested in determining the maximum percentage per combination of Quinary and Water Management Area, the code would slightly change:import arcpy
# your data:
tbl = r'C:\Project\_Forums\_maxDict\fgdb\test.gdb\aTable'
fld_quin = 'Quinary'
fld_wma = 'WMA' # Water Management Area
fld_perc = 'Percentage'
fld_oid = arcpy.Describe(tbl).OIDfieldname
# create empty dictionary to store results
dct = {}
# loop through table
flds = (fld_oid, fld_quin, fld_wma, fld_perc)
with arcpy.da.SearchCursor(tbl, flds) as curs:
for row in curs:
oid, perc = row[0], row[3]
quin, wma = row[1], row[2]
key = (quin, wma)
if key in dct:
max_perc = dct[key][1]
if perc > max_perc:
dct[key] = (oid, perc)
else:
dct[key] = (oid, perc)
# print results
for key, val in dct.items():
print val[0], key[0], key[1], val[1]
Kind regards,Xander