AnsweredAssumed Answered

Trying to reclassify a field in attribute table with Python in Field Calculator

Question asked by dmensah2 on Jul 10, 2015
Latest reply on Jul 10, 2015 by Dan_Patterson

Hello again!

 

I'm still relatively new to Python and it's my first time implementing it in the Field Calculator. What I am trying to accomplish is the reclassification of one field "CAUSE" into a new blank field named "CAUSE_RGR". I was given a script that I would have to adapt to this current project.

 

Basically I need to reclassify the numbers in the "CAUSE" column to be new numbers in the "CAUSE_RGR" as so:

 

1 --> 7

3 --> 2

4 --> 1

 

I was given a script that I would have to adapt to this current project, so I watched a tutorial on using python in the field calculator and came up with this script in the field calculator:

 

Pre-Logic Script Code:

 

def Reclass (CAUSE):

        if CAUSE == 1:

             return 7

        elif CAUSE == 3:

             return 2

        elif CAUSE == 4:

             return 1

        else:

             return 0

 

CAUSE_RGR =

 

def Reclass(!CAUSE!)

 

However I keep getting errors. Is it a syntax issue? I can't see why something as this isn't working.

Outcomes