I have a file geodatabase in ArcGIS with a list of parking transactions that include start and end time, and a zone. I want to calculate a field in each row that gives the occupancy in that transaction's zone at the start time, but keep receiving error messages from the expression and code block I use.
This is the expression: calculate_occupancy(!Zone!, !Parking_Start_date!, !Parking_End_date!)
Also, I am using the Calculate Field tool in Geoprocessing.
UPDATE:
I've fixed the syntax on the code block and now have this:
def calculate_occupancy(zone, start_date, end_date):
count = 0
table_name = r"./Default.gdb/Parkmobile"
field_names = ["Zone", "Parking_Start_date", "Parking_End_date"]
with arcpy.da.SearchCursor(table_name, field_names) as cursor:
for row in cursor:
if row[0] == zone and row[1] <= start_date and row[2] >= start_date:
count += 1
return count
The syntax checker confirms it is valid, but now I get the following error:
ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
Failed to evaluate Arcade expression. [
Rule name: Zone_Occ,
Triggering event: Update,
Class name: Parkmobile,
GlobalID: ,
Arcade error: Object not found $featureset,
Script line: 9]
Failed to execute (CalculateField).
This is confusing as $featureset is nowhere in my code. I have Python selected, but it seems like this is Arcade-related.
!Zone!etc.?