I am doing a project for a class right now in ArcGIS Pro where we are looking at population density with census data. Looking to map females 25-29 years old that are labeled as other race. The female/age and race are in two seperate fields amongst other gender/age and race fields. I want to be able to populate a new field marking the number of the gender/age and race given above but am not sure how.
This is what I've tried:
expression: OF25_29 = calc(!Other!,!F25_29!)
Code Block:
def calc(arg):
for !Other! >= 1 and !F25_29! >=1:
OF25_29 = !Other! + !F25_29!
for !Other! <1 and !F25_29! < 1:
OF25_29 = 0
I've never done a field calculation in Pro I admit, but unless the syntax has changed quite a bit here's my take on it:
Ensure the python parser is used.
I've also added an else to catch where condition 1 and 2 are not met (which I believe is a possibility)
expression = calc(!Other!, !F25_29!)
def calc(field1, field2):
if field1 >= 1 and field2 >=1:
result = field1 + field2
elif field1 <1 and field2 < 1:
result = 0
else:
result = -9999
return result