I've been using ArcGIS Pro over ArcMap recently because ArcMap is giving me some incorrect summary statistics that I use to populate a data field in a number of feature classes. The problem is that I'm not very familiar with Python and I haven't been able to translate my VB Script expressions into Python.

The expression considers two data fields from the summary statistics table for each unique Site ID and either gives the study panel number [LAST_panel], or the evaluation status [LAST_Eval_Status] if the status is either "Dormant" or "Reject" and enters a value into a "Panel_Status" field in a point feature class.

Pre-Logic Script Code:

dim PS

if [PARK_GRTS_EVAL_Statistics.LAST_Eval_Status]="Dormant" then
elseif [PARK_GRTS_EVAL_Statistics.LAST_Eval_Status]="Reject" then
else PS= [PARK_GRTS_EVAL_Statistics.LAST_panel]
end if

PARK_PCM_GRTS.Panel_Status =


In the expression above, PARK is a stand-in for a location code, since there are multiple locations and datasets I'm working with. The workaround I've been using is to create the summary statistics in ArcGIS Pro and then doing the field calculator in ArcMap 10.5 but it would be more efficient if I could do it all in ArcGIS Pro. Plus it would benefit me to learn a bit of Python.

How do I translate this into Python 3?


1 Answer 1


If I understand your question to simply be how to migrate the VB code into Python, see below. It's all basically the same, just minor differences in the syntax. The biggest syntax difference is the!fieldname!. This is how, using Python in the Calc Field tool you pass fields within the dataset into the code block.

Using Calc Field, you'll want to set Panel_Status == ifelse(!Eval_Status!, !Last_Panel!)

Code block:

def ifelse(evalstat, lastpanel):
    if evalstat == "Dormant":
        return "Dormant"
    elif evalstat == "Reject":
        return "Reject"
        return lastpanel


enter image description here


Your Answer

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

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