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])
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.