3

I'm trying to calculate a field using Python with field calculator but am running into a syntax error. I'm hoping someone can point out what the error is, and I can't seem to figure it out. Below is the code.

Unfortunately, BUS_YR is stored as a string. It has the last 2 digits of a year and I'm trying to convert it into an integer of the full year. So 96 becomes 1996 and 00 becomes 2000.

def Reclass(NEWYEAR):
 BUS_YR=int(BUS_YR)
 If BUS_YR > 90:
 return BUS_YR+1900
 Else: 
 return BUS_YR+2000
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Sep 15, 2017 at 15:41

2 Answers 2

5

if and else need to be lower case in Python

answered Sep 15, 2017 at 15:45
0
2

Here is how the code should read with the suggested correction (as mentioned previously) with if and else, lower cased.

def Reclass(NEWYEAR): 
 BUS_YR=int(BUS_YR) 
 if BUS_YR > 90: 
 return BUS_YR+1900 
 else: 
 return BUS_YR+2000 
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
answered Sep 15, 2017 at 16:24

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.