Numbering of records that have same ID with sequential numbers that start from zero,
For example, in the screenshot below, 4 buildings take (42/1/Beituniya) as their ID. What I need is to add new field (BuildingNumber) at which I want to stick sequential numbers for these buildings.
How this might be performed?
Thank you
Best
Jamal
Solved! Go to Solution.
You could try an update cursor like so:
import arcpy getMax = max([row[0] for row in arcpy.da.SearchCursor("TestPoints","FREQUENCY")]) +1 for i in range (getMax): j = 0 with arcpy.da.UpdateCursor("TestPoints",["FREQUENCY","BuildingNumber"]) as update: for row in update: if row[0] == i: row[1] = j j += 1 else: j = 0 update.updateRow(row)
Moved to Geoprocessing
Use the GeoNet Community Structure for better placement of questions.
You could try an update cursor like so:
import arcpy getMax = max([row[0] for row in arcpy.da.SearchCursor("TestPoints","FREQUENCY")]) +1 for i in range (getMax): j = 0 with arcpy.da.UpdateCursor("TestPoints",["FREQUENCY","BuildingNumber"]) as update: for row in update: if row[0] == i: row[1] = j j += 1 else: j = 0 update.updateRow(row)