2

I am trying to assign a value from one field of my attribute table to a new field based on the 3D field...

The code block I am thinking about is as follows:

def conditional (!FarmCateg!):
   if (FarmCateg=='4'):
       return 
        '''(and here I want to return values from "Percent Area" Field (float)):'''
   elif( ): return "0"

Expression: conditional(!FarmCateg!)

2 Answers 2

4

Try something like this where I have assumed that the third field you are wanting to update is of type float or double ...

Code Block:

def conditional (FarmCateg,PercentArea):
   if FarmCateg == '4':
       return PercentArea
   else:
       return 0.0

Expression:

conditional(!FarmCateg!,!PercentArea!)
2
  • Thank you, it helped, but in line2 I didn't use apostrophe for number 4, since it was already calculated value...
    – Irina
    Commented Nov 25, 2013 at 5:51
  • @Irina From your Comment I am not clear whether this is now resolved. If yes, but with a modification you made to the code I suggested, then I recommend that you edit my Answer to correct it and then Accept it.
    – PolyGeo
    Commented Nov 25, 2013 at 6:34
1

def conditional (FarmCateg,PercentArea): if FarmCateg == 4: return PercentArea else: return 0.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.