-2

In ArcGIS 10.5, I am building a model that should convert a field of coded values to another code. This seems like it should be a simple if/then statement but I am not getting it. To simplify the process, I populated the target field with the source field's values and then intend on using python to transpose the values. It should be considered a string, but the values are numerical.

In the "Calculate Field" code block:

def reclass:
if TP_Condi = 3:
return 1
elif TP_Condi = 2:
return 8
elif TP_Condi = 1:
return 3
else:
return "error"

2
  • Normally, equality in Python is tested with "==" rather than "=" as it is in SQL. Furthermore, you are mixing Integers and Strings as your return value. From your question I understand you want to have Strings in your new field, so either use return str(1) or just return '1' Commented Feb 23, 2018 at 16:55
  • 2
    Instead of posting the same question again, edit your question from yesterday and clarify the questions in the comments and you will get a correct answer. Commented Feb 23, 2018 at 16:57

1 Answer 1

0

I assume you are not getting a syntax error, so your indents are OK. I do notice you don't pass the field name in the function call (first Line). So it would not have any value.

def reclass([TP_Condi]):

I would use a join, not Python, to solve this problem, but to each his own..

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.