Below is the code with what I have come up with. I have two columns, one named First_kopp
that have the classes CT
, WT
, ST
ranging from 1-9, and the second column is named First-fros
. There are conditions that have to be met based on both columns as expressed in the code below, however, this code does not seem to work:
def reclass(FIRST_KOPP , FIRST_FROS):
if 'CT' in FIRST_KOPP:
return "High frost risk"
elif 'ST1' or 'ST2' or 'ST3' in FIRST_KOPP:
return "Frost free"
elif 'ST1' or 'ST2' or 'ST3' in FIRST_KOPP and 'Moderate frost risk' or 'High frost risk' in FIRST_FROS:
return "Low frost risk"
elif 'ST4' or 'ST5' or 'ST6' or 'ST7' or 'ST8' or 'ST9' in FIRST_KOPP:
return "Frost free"
elif 'WT' in FIRST_KOPP and 'Frost free' in FIRST_FROS:
return "Low frost risk"
else:
return FIRST_FROS
1 Answer 1
I have managed to get the script to work. After every or
it is important to state in which column. Such as ST1 in Frost_Kopp
or ST2 in Frost_kopp
, etc
-
your first two "elif" condition test both for "'ST1' or 'ST2' or 'ST3' in FIRST_KOPP" regardless of syntax issue if the firsts is true the second wont be evaluated....J.R– J.R2022年02月15日 17:19:38 +00:00Commented Feb 15, 2022 at 17:19
Explore related questions
See similar questions with these tags.
elif any(x in FIRST_KOPP for x in ['ST1','ST2','ST3'])