I use the following logic in ModelBuilder to get a result as seen below:
A feature class has a Column with the name "Value" which is passed through to the Summary Statistics Tools which calculates the Mean of the Column "Value".
The Get value tool then retrieves this from the summary table created and passes it to the calculate field tool. This one value is then added to all the row in the column named Mean.
arcpy.Statistics_analysis(outPRJ, r"C:/Users/dean/Desktop/Script Dependencies/03_Output/4_Stats/minValue.dbf",
[["Value", "MIN"]])
tableMin = r"C:/Users/dean/Desktop/Script Dependencies/03_Output/4_Stats/minValue.dbf"
fieldMin = ["MIN_Value"]
with arcpy.SearchCursor(tableMin, fieldMin) as cursor:
for row in cursor:
MinValue = print("MIN_Value: {}")
arcpy.CalculateFields_management(outPRJ, "Min", MinValue, "PYTHON_9.3")
I want to use the same logic in a python script by using a search cursor and tried the code below which gives me an error. The Error received is the following:
Traceback (most recent call last):
File "D:/Dropbox Data/Dropbox/02_Agrimotion/ZZZ_Scripts/Chem Soil Interpolation - Updated Header Names.py", line 189, in <module>
with arcpy.SearchCursor(tableMin, fieldMin) as cursor:
AttributeError: __enter__
Statistics Analysis
which is based on one single column and does not vary based on another field. You want this same value to be added to every single row. You have already added a variable MinValue which holds this value from the (last row within the) minValue table. Instead of using!Min_Value!
(a field name from a different table) in your calculate field, useMinValue
(the variable created fromSearchCursor
code). @PolyGeo if you reopen I can add this as an answer.