For this you can use [UpdateCursor][1], which opens the feature class or table and steps through each record (row) incrementally. The script below works on this test data +-----------------------+ | Time| Home_Away|Trip | +-----|----------|------+ | 1 | 0 | <nul>| | 2 | 1 | <nul>| | 4 | 1 | <nul>| | 5 | 0 | <nul>| | 6 | 0 | <nul>| | 7 | 1 | <nul>| | 9 | 1 | <nul>| | 12 | 1 | <nul>| | 13 | 0 | <nul>| +-----------------------+ . import arcpy fc = r'D:\s\py\pyscratch.gdb\gps_points' # open the feature class and create the cursor rows = arcpy.UpdateCursor(fc) trip = 0 for row in rows: if row.HOME_AWAY == 0: trip += 1 # start of new trip, increment counter row.TRIP = trip # calc the TRIP field to be current trip# rows.updateRow(row) # save print "Trip %s started at %s" % (trip, row.TIME) # keep cycling through records until HOME_AWAY is not 1 while row.HOME_AWAY == 1: row.TRIP = trip rows.updateRow(row) rows.next() # move to next record # this is for the trailing end of a trip # print " %s ended at %s" % (trip, row.TIME) row.TRIP = trip rows.updateRow(row) # remove programming objects and data locks # the data itself is left alone del row, rows The trailing end of trip block is actually run for the beginning of a trip also, but since the trip counter is correct the double calc on the begin-trip-row doesn't matter . Uncomment the print statement in that block to see what I mean. Python automatically adds an implicit `rows.next()` at the end for the `for row in rows` block. [1]: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v0000003m000000