In field calculator i calculate sequential values in field [ORDER_ID]
What need change in script to calculate sequential values based on group field [GROUP_ID]. I select values manually and use autoincrement () in Field Calculator.
Parser: Python
Expression: autoIncrement()
Pre-Logic Script Code:
rec=0
def autoIncrement():
global rec
pStart = 1
pInterval = 1
if (rec == 0):
rec = pStart
else:
rec = rec + pInterval
return rec
This is the result.
Field ORDER_ID is already calculated manually (i select GROUP_ID and use autoincrement).
What changes script needed to use it in field calculator?
Best Answer
You can do this with an UpdateCursor easily in the Python Window:
where the
your_lyr
variable is a reference to the table you're updating.