I am trying to get field values from one table and use them to perform calculations on a row in another fc table. Does anyone have any ideas on how to make this run faster? I've tried a dictionary but am having problems when i try to reassign a value in the dictionary.
import arcpy
import numpy as np
arcpy.env.workspace = "C:\Users\michellep\Documents\project.gdb"
print "Arcpy & Numpy imported successfully and workspace set"
print "Start Processing"
start = time.time()
#define variables
group = "Test_Group"
fields = ['ObjectID', 'R', 'A', 'Total']
pc = "PC_Table"
cursor = arcpy.da.UpdateCursor(group, fields)
#row = cursor.next()
for row in cursor:
R = row[0]
A = row[1]
arcpy.CalculateField_management(pc, "R", R, "PYTHON", "")
arcpy.CalculateField_management(pc, "A", A, "PYTHON", "")
arcpy.CalculateField_management(pc, "WVal", "!R! / !A! * (!B! / !A!)**(!R!-1), "PYTHON", "")
arcpy.CalculateField_management(pc, "Hours", "!WVal! * !K!", "PYTHON", "")
arr = arcpy.da.TableToNumPyArray(pc, "Hours")
arr.dtype = np.dtype(float)
row[2] = np.sum(arr)
cursor.updateRow(row)
del row
del cursor
end = time.time()
processTime = end - start
print "Processing Completed - {:.1f} seconds".format(processTime)
"
in your thirdCalculateField
line.