Select to view content in your preferred language

python

855
4
Jump to solution
03-22-2020 03:38 AM
KalSsin
Regular Contributor

Hi~~~

def Reclass(arg):
    if arg in ["222", "333"]:
        return "<Null>"
    else:
        return arg

I want the results as shown below.

0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

Do not return "<NULL>" because it will not set a field to SQL NULL, it will set a field to a text string that says "<NULL>".  If you want to set a field to SQL NULL, you want to return None.

View solution in original post

4 Replies
DavidPike
MVP Frequent Contributor

Nearly there, but you need to pass in 2 arguments.

#prelogic codeblock

def Reclass(arg1, arg2):
    if arg1 in ["222", "333"]:
        return "<Null>"
    else:
        return arg2


#code

Reclass(!NAME!, !PNAME!)
KalSsin
Regular Contributor

Thank you so much~~~~~~

#prelogic codeblock
def Reclass(arg1, arg2):
    if arg1 in ["222", "333"]:
        return None
    else:
        return arg2

#code
Reclass(!NAME!, !PNAME!)

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Do not return "<NULL>" because it will not set a field to SQL NULL, it will set a field to a text string that says "<NULL>".  If you want to set a field to SQL NULL, you want to return None.

KalSsin
Regular Contributor

Thank you

0 Kudos