I need to convert this code to be used by python in ArcGIS
if [Field_1] < [Field_2] : pd = [Field_1] else: pd = [Field_2]
I need to convert this code to be used by python in ArcGIS
if [Field_1] < [Field_2] : pd = [Field_1] else: pd = [Field_2]
for a shorter code, you could use the built in "min" function to avoid the use of a code block. "min" can be used for more than one field.
min(!field1!,!field2!)
if [Field_1] < [Field_2]:
pd = [Field_1]
else:
pd = [Field_2]
In this example it is pretty simple. Look over this page for more examples on if statements.
If you are interested in learning more about utilizing Python in the GIS realm, please read this thread.
! instead of [] for use with Python. Also, be sure to handle the case where !Field_1! == !Field_2!. +1 for the links!
– Martin
May 11 '15 at 13:13