I have a lot of rows of data, and I want to use the field calculator to give a uniform assignment of
0 1 0 1 0 1 ...
but I don't know how to implement it.
Can someone help me?
Use this advanced field calculator expression (Python):
i=0 def switch(): global i i=1-i return i *------- switch()
As @PolyGeo mentioned, the modulo operator helps you determine whether a number is pair or not. You can check the "Show Codeblock" box in the field calculator and then write a simple function that determines wheter the row is pair or not and adds a 0 or a 1 depending on the condition
def calc(fid): if fid % 2 != 0: return 0 else: return 1
Then, in the box under you jsut have to call the function using the FID field as an argument.
calc( !FID! )
Note: make sure python is checked as the parser.