I am trying to add a new field (float data type) and using existing fields to calculate the new field.
So far, I have:
import arcpy path = 'pathname' #in my code, this is actually the path name arcpy.env.workspace = path fclist = arcpy.ListFeatureClasses() fc = fclist prop = 'PrYouth' #name of new field ftype = "FLOAT" #Type of new field thisField = arcpy.ListFields(fc, prop) if len(thisField) == 0: #if length = 0 aka it does not exist yet, add field arcpy.AddField_management(fc, prop, ftype, "5", "4") # 5 is precision, 4 is scale else: #delete field then add new again arcpy.DeleteField_management(fc, prop) arcpy.AddField_management(fc, prop, ftype, "5", "4") # 5 is precision, 4 is scale with arcpy.da.UpdateCursor(fc, ['AGE_UNDER5','AGE_5_17','POP2000', prop]) as cursor: for row in cursor: kids = row + row  row = (kids/row) cursor.updateRow(row)
I am unable to update the precision and scale values for float. I've tried to specify using field_precision = 5 and field_scale = 4, but this doesn't seem to work.
Also, how do I get the new field to calculate for the proportion? Am I using the right syntax?
Currently, I am only able to add the field and fill the list with 0.