The following code isn't working as expected and I'm not sure why:

  UpOrDown = reclass(!UpOrDown!) 
  def reclass (Z,GP):
   if (GP == "DT" and Z == "CG"):
    UpOrDown = 1
   if (GP == "DT" and Z == "CN"):
    UpOrDown = 1
   if (GP == ...and so on.... )

The expression is passing as valid but the wrning (warning 002858) suggests that there is a TypeError in reclass() which is missing the argument 'G'.

enter image description here

I have added this into the code at UpOrDown = reclass(!UpOrDown!,!G!) which returns no error but doesn't output the expected variable of 1 in the UpOrDown column (which is Double).

I also changed the dependent variables to both Z and GP which still didn't change anything.

enter image description here

What is missing?

  • 3
    You have one argument reclass(!UpOrDown!) and two in the arglist def reclass (Z,GP) and you don't show what is returned. Look again at the documentation. 1) same number of arguments, 2) return a singleton value
    – Vince
    May 20, 2020 at 21:47
  • I took your advice but it's still not working.
    – Therow
    May 20, 2020 at 22:02
  • 4
    As @Vince mentioned, you need a return statement in your function. At the end, type return UpOrDown.
    – Fezter
    May 20, 2020 at 22:05
  • 2
    Please always provide errors as formatted text rather than pictures. That way they are available to future searches by others stuck at the same place, and be easily readable on all devices.
    – PolyGeo
    May 20, 2020 at 22:44
  • You should also use elif in your conditional logic (or return 1 instead of not returning the set variable)
    – Vince
    May 21, 2020 at 2:21

1 Answer 1


The field calculator needs to return a value that will be populated onto your field. Your current code just sets a variable UpOrDown, it doesn't tell the calculator what to write.

Additionally you should use elif rather than if for your subsequent lines so that the parser only processes what it needs to, and then finish up with an else to handle what happens if none of the if/elif do anything.

reclass(!Parcels_Zoning_Interest_ZONINGABBREV!, !GPABBREVIATION!)

def reclass (Z,GP):
    if (GP == "DT" and Z == "CG"):
        UpOrDown = 1
    elif (GP == "DT" and Z == "CN"):
        UpOrDown = 2
    elif (GP ==  "this" and Z == "that" ):
        UpOrDown = 3
        UpOrDown = 0

    return UpOrDown

Your Answer

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

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