1

I'm using ArcGIS Pro, the field calculator. I want to populate a hydrant layer with hydrant inspection data. I have two fields from a joined table: field 1 and field 2. I want to populate field 1 with the values from field 2, but only if the values ARE NOT Null. Basically I want to preserve the values in field 1 if the corresponding value in field 2 is Null. I've been trying slight variations of the python code below. But it just populates field 1 with all of field 2 whether there are nulls or not.

I'm a beginner when it comes to Python.

Codeblock:

def reclass(f1,f2):
        if f2 is not None:
            return f2
        else:
            pass

Expression:

reclass(!field1!,!field2!)
2

I figured it out!

Expression:

Reclass(!field1!,!field2!)

Codeblock:

 def Reclass(f1,f2):
        if f2 is None:
            return f1
        else: 
            return f2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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