table = "my_table" field_to_sort = "a" field_to_rank = "b" # Make a sorted set of values in table with arcpy.da.cursor(table, field_to_sort) as cursor: sorted_items = sorted( { row[0] for row in cursor } ) # Rank based on order sorted_ranking = { item: index + 1 for index, item in enumerate(sorted_items) } with arcpy.da.UpdateCursor(table, [field_to_sort, field_to_rank]) as cursor: for value, rank_value in cursor: new_rank_value = sorted_ranking[value] cursor.updateRow([value, new_rank_value])
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.